Skip to content

Commit

Permalink
Fix: Support JVM version string from old (< v8.9) and new (>= v8.9) g…
Browse files Browse the repository at this point in the history
…radle version (#683)

* fix(validator): support version string from old and newest gradle

* fix(test): fix unit test

* test: add more version and runtime to the test

* refactor(validator): use full label instead

* fix(validator): use in operator to check JVM substring

---------

Co-authored-by: Mehmet Nuri Deveci <[email protected]>
  • Loading branch information
jeffryang24 and mndeveci authored Nov 15, 2024
1 parent 2b1aee1 commit 2a2d6b7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
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

0 comments on commit 2a2d6b7

Please sign in to comment.