Skip to content

Commit

Permalink
fix: Restrict the condition for Gradle JVM string (#706)
Browse files Browse the repository at this point in the history
* fix: Restrict the condition for Gradle JVM string to make sure it doesn't parse the wrong one

* Fix format
  • Loading branch information
dkphm authored Nov 22, 2024
1 parent 5c8dae8 commit a3b0f90
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
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 "JVM" in l_dec:
if l_dec.startswith("JVM") or l_dec.startswith("Launcher JVM"):
return l_dec
10 changes: 8 additions & 2 deletions tests/unit/workflows/java_gradle/test_gradle_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ def test_emits_warning_when_gradle_excutable_fails(self):
validator.validate(runtime_path=self.runtime_path)
self.mock_log.warning.assert_called_with(GradleValidator.VERSION_STRING_WARNING, self.runtime_path)

def test_emits_warning_when_version_string_not_found(self):
version_string = "The Java Version: 9.0.0".encode()
@parameterized.expand(
[
"The Java Version: 9.0.0",
"Daemon JVM: /Library/Java/JavaVirtualMachines/amazon-corretto-21.jdk/Contents/Home (no JDK specified, using current Java home)",
]
)
def test_emits_warning_when_version_string_not_found(self, path):
version_string = path.encode()
self.mock_os_utils.popen.side_effect = [FakePopen(stdout=version_string, returncode=0)]
validator = GradleValidator(
runtime=self.runtime, architecture=self.architecture, os_utils=self.mock_os_utils, log=self.mock_log
Expand Down

0 comments on commit a3b0f90

Please sign in to comment.