Skip to content

Commit 697a7b8

Browse files
authored
Merge pull request #14702 from github/criemen/java-int-test
Java: Make integration test more robust wrt recent Java versions.
2 parents a0e73ea + ccaa792 commit 697a7b8

File tree

1 file changed

+9
-7
lines changed
  • java/ql/integration-tests/all-platforms/java/diagnostics/java-version-too-old

1 file changed

+9
-7
lines changed

java/ql/integration-tests/all-platforms/java/diagnostics/java-version-too-old/test.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
from diagnostics_test_utils import *
44

55
# Ensure we're using an old Java version that won't work with Gradle
6-
if "JAVA_HOME_8_X64" in os.environ:
7-
os.environ["JAVA_HOME"] = os.environ["JAVA_HOME_8_X64"]
8-
sep = ";" if platform.system() == "Windows" else ":"
9-
os.environ["PATH"] = "".join([os.path.join(os.environ["JAVA_HOME"], "bin"), sep, os.environ["PATH"]])
6+
for k in os.environ:
7+
if k.upper() in ["JAVA_HOME_8_X64", "JAVA_HOME_8_ARM64"]:
8+
os.environ["JAVA_HOME"] = os.environ[k]
9+
sep = ";" if platform.system() == "Windows" else ":"
10+
os.environ["PATH"] = "".join([os.path.join(os.environ["JAVA_HOME"], "bin"), sep, os.environ["PATH"]])
11+
break
1012

11-
# Ensure the autobuilder *doesn't* see Java 11 or 17, which it could switch to in order to build the project:
12-
for k in ["JAVA_HOME_11_X64", "JAVA_HOME_17_X64"]:
13-
if k in os.environ:
13+
# Ensure the autobuilder *doesn't* see newer Java versions, which it could switch to in order to build the project:
14+
for k in os.environ:
15+
if re.match(r"^JAVA_HOME_\d\d_", k):
1416
del os.environ[k]
1517

1618
# Use a custom, empty toolchains.xml file so the autobuilder doesn't see any Java versions that may be

0 commit comments

Comments
 (0)