Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making the correct Parsing #890

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions TestResultSummaryService/parsers/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,45 @@ class Parser {
const javaVersionRegex =
/=JAVA VERSION OUTPUT BEGIN=[\r\n]+([\s\S]*?)[\r\n]+.*=JAVA VERSION OUTPUT END=/;
const javaBuildDateRegex =
/\s([0-9]{4})-?(0[1-9]|1[012])-?(0[1-9]|[12][0-9]|3[01])/;
/(\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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no javaVersionRegex match, we have no idea where the java -version is from and we should not handle the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case than should i use return null instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, in this case, there is no java -version output.

}

curRegexResult = null;
if ((curRegexResult = sdkResourceRegex.exec(output)) != null) {
sdkResource = curRegexResult[1];
}
curRegexResult = null;
// parse jdk date from javaVersion

// 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 @@ -102,7 +125,7 @@ class Parser {
let versions = {};

const releaseInfoRegex =
/=RELEASE INFO BEGIN=\n[\s\S]*?SOURCE="(.*)"[\s\S]*?=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
Loading