Skip to content

Commit

Permalink
Update Parser.js
Browse files Browse the repository at this point in the history
Update the parsing depending on the jdk implementation is used
  • Loading branch information
Sangyoon21 authored Jul 17, 2024
1 parent 65e1059 commit 408edd3
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions TestResultSummaryService/parsers/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,45 @@ class Parser {
const javaVersionRegex =
/=JAVA VERSION OUTPUT BEGIN=[\r\n]+([\s\S]*?)[\r\n]+.*=JAVA VERSION OUTPUT END=/;
const javaBuildDateRegex =
/Eclipse OpenJ9 VM \(build [^,]+, JRE [^\s]+ [^\s]+ [^\s]+ (\d{8})_/;
/(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])/; // Captures dates in the format YYYY-MM-DD
const sdkResourceRegex = /.*?SDK_RESOURCE\=(.*)[\r\n]+/;
let curRegexResult = null;
let javaVersion, jdkDate, sdkResource;

if ((curRegexResult = javaVersionRegex.exec(output)) !== null) {
javaVersion = removeTimestamp(curRegexResult[1]);
} else {
javaVersion = output; // Use the entire output if markers are missing
}

curRegexResult = null;
if ((curRegexResult = sdkResourceRegex.exec(output)) != null) {
sdkResource = curRegexResult[1];
}
curRegexResult = null;
// parse jdk date from javaVersion
if ((curRegexResult = javaBuildDateRegex.exec(output)) !== null) {
jdkDate = curRegexResult[1].trim(); // Ensure the date is trimmed
// Convert jdkDate from YYYYMMDD to YYYY-MM-DD
jdkDate = `${jdkDate.substring(0, 4)}-${jdkDate.substring(4, 6)}-${jdkDate.substring(6, 8)}`;
console.log('Parsed jdkDate:', jdkDate); // Log statement to show jdkDate

// parse jdk date from javaVersion or output
if ((curRegexResult = javaBuildDateRegex.exec(javaVersion)) !== null) {
jdkDate = curRegexResult[0];
} else if ((curRegexResult = javaBuildDateRegex.exec(output)) !== null) {
jdkDate = curRegexResult[0];
}

// Refine jdkDate extraction to match specific lines for HotSpot and OpenJ9 implementations
if (jdkDate === null) {
// Try to extract date from specific lines for HotSpot
const hotspotBuildDateRegex =
/OpenJDK Runtime Environment [^ ]+ \([^)]+ (\d{4})(\d{2})(\d{2})/; // e.g., 20240626
const openj9BuildDateRegex =
/Eclipse OpenJ9 VM \([^)]+ (\d{4})(\d{2})(\d{2})/; // e.g., 20240627

if ((curRegexResult = hotspotBuildDateRegex.exec(output)) !== null) {
jdkDate = `${curRegexResult[1]}-${curRegexResult[2]}-${curRegexResult[3]}`;
} else if ((curRegexResult = openj9BuildDateRegex.exec(output)) !== null) {
jdkDate = `${curRegexResult[1]}-${curRegexResult[2]}-${curRegexResult[3]}`;
}
}

return { javaVersion, jdkDate, sdkResource };
}

Expand Down Expand Up @@ -105,7 +125,7 @@ class Parser {
let versions = {};

const releaseInfoRegex =
/=RELEASE INFO BEGIN=\n[\s\S]*?SOURCE="(.*)"[\r\n]+.*=RELEASE INFO END=/;
/=RELEASE INFO BEGIN=\n[\s\S]*?SOURCE="(.*)"\n[\s\S]*?=RELEASE INFO END=/;
const generalOpenjdkShaRegex = /git:(.*)/;
const openjdkShaRegex = /OpenJDK:\s?([^\s\:]*)/;
const j9AndOmrShaRegex = /OpenJ9:\s?([^\s\:]*).*OMR:\s?([^\s\:]*)/;
Expand Down

0 comments on commit 408edd3

Please sign in to comment.