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

Fix: Support JVM version string from old (< v8.9) and new (>= v8.9) gradle version #683

Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,5 @@ def _get_jvm_string(self, gradle_path):

for line in stdout.splitlines():
l_dec = decode(line)
if l_dec.startswith("JVM"):
if "JVM" in l_dec:
return l_dec
34 changes: 34 additions & 0 deletions tests/unit/workflows/java_gradle/test_gradle_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,40 @@ def test_emits_warning_when_version_string_not_found(self):
validator.validate(runtime_path=self.runtime_path)
self.mock_log.warning.assert_called_with(GradleValidator.VERSION_STRING_WARNING, self.runtime_path)

@parameterized.expand(
[
("1.8.0", "java8"),
("11.0.0", "java11"),
("17.0.0", "java17"),
("21.0.0", "java21"),
]
)
def test_does_not_emit_warning_for_version_string_in_gradle_lt_8_9(self, version, runtime):
version_string = f"JVM: {version}".encode()
self.mock_os_utils.popen.side_effect = [FakePopen(stdout=version_string, returncode=0)]
validator = GradleValidator(
runtime=runtime, architecture=self.architecture, os_utils=self.mock_os_utils, log=self.mock_log
)
validator.validate(runtime_path=self.runtime_path)
self.mock_log.warning.assert_not_called()

@parameterized.expand(
[
("1.8.0", "java8"),
("11.0.0", "java11"),
("17.0.0", "java17"),
("21.0.0", "java21"),
]
)
def test_does_not_emit_warning_for_version_string_in_gradle_ge_8_9(self, version, runtime):
version_string = f"Launcher JVM: {version}".encode()
self.mock_os_utils.popen.side_effect = [FakePopen(stdout=version_string, returncode=0)]
validator = GradleValidator(
runtime=runtime, architecture=self.architecture, os_utils=self.mock_os_utils, log=self.mock_log
)
validator.validate(runtime_path=self.runtime_path)
self.mock_log.warning.assert_not_called()

@parameterized.expand(
[
("11.0.0", "java11"),
Expand Down
Loading