Skip to content

Commit

Permalink
Merge pull request #479 from yanokwa/java-11-hotfix
Browse files Browse the repository at this point in the history
Java versions can have patch versions
  • Loading branch information
yanokwa authored Nov 14, 2020
2 parents 9520bd2 + 8985b4b commit 5ae984f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions pyxform/tests_v1/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
OpenJDK Runtime Environment (build 9-internal+0-2016-04-14-195246.buildd.src)
OpenJDK 64-Bit Server VM (build 9-internal+0-2016-04-14-195246.buildd.src, mixed mode)
"""
OPENJDK_11_PATCH = """openjdk version "11.0.9.1" 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)
"""


class TestValidators(TestCase):
Expand Down Expand Up @@ -76,3 +80,7 @@ def test_check_java_version(self):
with patch(mock_func) as mock_popen:
mock_popen.return_value = (0, False, "", OPENJDK_9_INT)
check_java_version()

with patch(mock_func) as mock_popen:
mock_popen.return_value = (0, False, "", OPENJDK_11_PATCH)
check_java_version()
6 changes: 3 additions & 3 deletions pyxform/validators/odk_validate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ def check_java_version():
# Using regex to find that in the string
java_version = re.findall(r"\"(.+?)\"", java_version_str)[0]
if "." in java_version:
major, minor, _ = java_version.split(".")
major, minor = java_version.split(".")[0], java_version.split(".")[1]
elif "-" in java_version:
major, minor = int(java_version.split("-")[0]), 0
major, minor = java_version.split("-")[0], 0
else:
major, minor = int(java_version), 0
major, minor = java_version, 0
if not ((int(major) == 1 and int(minor) >= 8) or int(major) >= 8):
raise EnvironmentError(
"pyxform odk validate dependency: " "java 8 or newer version not found"
Expand Down

0 comments on commit 5ae984f

Please sign in to comment.