Improved Java version parsing (#138155)
Fixes #135402 Add fallback logic for a different format of java version output and handle no patch versions. Add tests for new logic output to prevent regressions.
This commit is contained in:
@@ -280,6 +280,26 @@ OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
|
||||
expect(version.toString(), 'openjdk 19.0 2023-01-17');
|
||||
expect(version, equals(Version(19, 0, null)));
|
||||
});
|
||||
|
||||
testWithoutContext('parses jdk 21 with patch numbers', () {
|
||||
addJavaVersionCommand('''
|
||||
java 21.0.1 2023-09-19 LTS
|
||||
Java(TM) SE Runtime Environment (build 21+35-LTS-2513)
|
||||
Java HotSpot(TM) 64-Bit Server VM (build 21+35-LTS-2513, mixed mode, sharing)
|
||||
''');
|
||||
final Version? version = java.version;
|
||||
expect(version, equals(Version(21, 0, 1)));
|
||||
});
|
||||
|
||||
testWithoutContext('parses jdk 21 with no patch numbers', () {
|
||||
addJavaVersionCommand('''
|
||||
java 21 2023-09-19 LTS
|
||||
Java(TM) SE Runtime Environment (build 21+35-LTS-2513)
|
||||
Java HotSpot(TM) 64-Bit Server VM (build 21+35-LTS-2513, mixed mode, sharing)
|
||||
''');
|
||||
final Version? version = java.version;
|
||||
expect(version, equals(Version(21, 0, 0)));
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user