-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
65e1059
408edd3
25e17a5
6b40ea7
c7811fe
17fd5a8
686bec8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
const Parser = require('./Parser'); // Adjust the path if necessary | ||
|
||
describe('Parser', () => { | ||
let parser; | ||
|
||
beforeEach(() => { | ||
parser = new Parser('TestBuild'); | ||
}); | ||
|
||
test('should extract Java version and build date for HotSpot implementation', () => { | ||
const hotspotOutput = ` | ||
16:38:54 =JAVA VERSION OUTPUT BEGIN= | ||
16:38:54 openjdk version "21.0.4-beta" 2024-07-16 | ||
16:38:54 OpenJDK Runtime Environment Temurin-21.0.4+6-202406261902 (build 21.0.4-beta+6-ea) | ||
16:38:54 OpenJDK 64-Bit Server VM Temurin-21.0.4+6-202406261902 (build 21.0.4-beta+6-ea, mixed mode, sharing) | ||
16:38:54 =JAVA VERSION OUTPUT END= | ||
`; | ||
|
||
const result = parser.exactJavaVersion(hotspotOutput); | ||
expect(result.jdkDate).toBe('2024-06-26'); | ||
}); | ||
|
||
test('should extract Java version and build date for OpenJ9 implementation', () => { | ||
const openj9Output = ` | ||
11:53:15 =JAVA VERSION OUTPUT BEGIN= | ||
11:53:19 openjdk version "11.0.24-internal" 2024-07-16 | ||
11:53:19 OpenJDK Runtime Environment (build 11.0.24-internal+0-adhoc.jenkins.BuildJDK11aarch64macPersonal) | ||
11:53:19 Eclipse OpenJ9 VM (build master-2a2df9f1117, JRE 11 Mac OS X aarch64-64-Bit 20240627_514 (JIT enabled, AOT enabled) | ||
11:53:19 OpenJ9 - 2a2df9f1117 | ||
11:53:19 OMR - 47a9d248db0 | ||
11:53:19 JCL - c535515f053 based on jdk-11.0.24+6) | ||
11:53:19 =JAVA VERSION OUTPUT END= | ||
`; | ||
|
||
const result = parser.exactJavaVersion(openj9Output); | ||
expect(result.jdkDate).toBe('2024-06-27'); | ||
}); | ||
|
||
test('should extract Java version and build date for Java 8 implementation', () => { | ||
const java8Output = ` | ||
16:38:54 =JAVA VERSION OUTPUT BEGIN= | ||
16:38:54 openjdk version "1.8.0_412" | ||
16:38:54 OpenJDK Runtime Environment (Temurin)(build 1.8.0_412-b08) | ||
16:38:54 OpenJDK 64-Bit Server VM (Temurin)(build 25.412-b08, mixed mode) | ||
16:38:54 =JAVA VERSION OUTPUT END= | ||
`; | ||
|
||
const result = parser.exactJavaVersion(java8Output); | ||
expect(result.jdkDate).toBe('2024-06-27'); // Adjust the expected date based on your requirements | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How do we get There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This was the part where i was not sure and had asked in the previous comment, so i had just added an random date. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case, there is no jdk build date in |
||
}); | ||
|
||
test('should extract Java version and build date for Java 8u152-b01 implementation', () => { | ||
const java8u152Output = ` | ||
16:38:54 =JAVA VERSION OUTPUT BEGIN= | ||
16:38:54 openjdk version "1.8.0_152" | ||
16:38:54 OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_152-b01) | ||
16:38:54 OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.152-b01, mixed mode) | ||
16:38:54 =JAVA VERSION OUTPUT END= | ||
`; | ||
|
||
const result = parser.exactJavaVersion(java8u152Output); | ||
expect(result.jdkDate).toBe('2024-06-27'); // Adjust the expected date based on your requirements | ||
}); | ||
|
||
test('should extract Java version and build date for Java 9.0.4+11 implementation', () => { | ||
const java904Output = ` | ||
16:38:54 =JAVA VERSION OUTPUT BEGIN= | ||
16:38:54 openjdk version "9.0.4" | ||
16:38:54 OpenJDK Runtime Environment (build 9.0.4+11) | ||
16:38:54 OpenJDK 64-Bit Server VM (build 9.0.4+11, mixed mode) | ||
16:38:54 =JAVA VERSION OUTPUT END= | ||
`; | ||
|
||
const result = parser.exactJavaVersion(java904Output); | ||
expect(result.jdkDate).toBe('2024-06-27'); // Adjust the expected date based on your requirements | ||
}); | ||
|
||
test('should extract Java version and build date for Java 10.0.2+13.1 implementation', () => { | ||
const java1002Output = ` | ||
16:38:54 =JAVA VERSION OUTPUT BEGIN= | ||
16:38:54 openjdk version "10.0.2" | ||
16:38:54 OpenJDK Runtime Environment (build 10.0.2+13.1) | ||
16:38:54 OpenJDK 64-Bit Server VM (build 10.0.2+13.1, mixed mode) | ||
16:38:54 =JAVA VERSION OUTPUT END= | ||
`; | ||
|
||
const result = parser.exactJavaVersion(java1002Output); | ||
expect(result.jdkDate).toBe('2024-06-27'); // Adjust the expected date based on your requirements | ||
}); | ||
|
||
test('should extract Java version and build date for Java 11.0.4+11.4 implementation', () => { | ||
const java1104Output = ` | ||
16:38:54 =JAVA VERSION OUTPUT BEGIN= | ||
16:38:54 openjdk version "11.0.4" | ||
16:38:54 OpenJDK Runtime Environment (build 11.0.4+11.4) | ||
16:38:54 OpenJDK 64-Bit Server VM (build 11.0.4+11.4, mixed mode) | ||
16:38:54 =JAVA VERSION OUTPUT END= | ||
`; | ||
|
||
const result = parser.exactJavaVersion(java1104Output); | ||
expect(result.jdkDate).toBe('2024-06-27'); // Adjust the expected date based on your requirements | ||
}); | ||
|
||
test('should extract Java version and build date for Java 13+33_openj9-0.16.0 implementation', () => { | ||
const java1333Output = ` | ||
16:38:54 =JAVA VERSION OUTPUT BEGIN= | ||
16:38:54 openjdk version "13" | ||
16:38:54 OpenJDK Runtime Environment (build 13+33) | ||
16:38:54 Eclipse OpenJ9 VM (build 13+33_openj9-0.16.0, JRE 13 Mac OS X aarch64-64-Bit) | ||
16:38:54 =JAVA VERSION OUTPUT END= | ||
`; | ||
|
||
const result = parser.exactJavaVersion(java1333Output); | ||
expect(result.jdkDate).toBe('2024-06-27'); // Adjust the expected date based on your requirements | ||
}); | ||
}); |
There was a problem hiding this comment.
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 thejava -version
is from and we should not handle the case.There was a problem hiding this comment.
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?There was a problem hiding this comment.
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.