diff options
author | robot-piglet <robot-piglet@yandex-team.com> | 2025-03-05 12:26:59 +0300 |
---|---|---|
committer | robot-piglet <robot-piglet@yandex-team.com> | 2025-03-05 12:48:59 +0300 |
commit | 7ede2d6c2889340f253fdbdc44992bc2b009c03a (patch) | |
tree | bd1de87db0b5ee9f0eedea3546ac21328958803c /library/python/testing | |
parent | 472e032cff4a665bad47e1470a4440682ca1166e (diff) | |
download | ydb-7ede2d6c2889340f253fdbdc44992bc2b009c03a.tar.gz |
Intermediate changes
commit_hash:2a363fa0f479cb30e3e9e6d9a9c9ffa92112ecf1
Diffstat (limited to 'library/python/testing')
-rw-r--r-- | library/python/testing/yatest_common/yatest/common/runtime_java.py | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/library/python/testing/yatest_common/yatest/common/runtime_java.py b/library/python/testing/yatest_common/yatest/common/runtime_java.py index f0f0f53cf01..49e41e3be78 100644 --- a/library/python/testing/yatest_common/yatest/common/runtime_java.py +++ b/library/python/testing/yatest_common/yatest/common/runtime_java.py @@ -1,10 +1,12 @@ import os +import re import tarfile import contextlib from . import runtime _JAVA_DIR = [] +_JDK_RE = re.compile(r'jdk(\d+)\.tar') def get_java_path(jdk_dir): @@ -28,19 +30,31 @@ def get_java_path(jdk_dir): def get_build_java_dir(jdk_dir): - versions = [8, 10, 11, 12, 13, 14, 15, 16, 17] - - if not _JAVA_DIR: - for version in versions: - jdk_tar_path = os.path.join(jdk_dir, "jdk{}.tar".format(version)) - if os.path.exists(jdk_tar_path): - jdk_dir = runtime.build_path('jdk4test') - with contextlib.closing(tarfile.open(jdk_tar_path)) as tf: - tf.extractall(jdk_dir) - assert os.path.exists(os.path.join(jdk_dir, "bin", "java")) - _JAVA_DIR.append(jdk_dir) - break - else: - _JAVA_DIR.append(None) - - return _JAVA_DIR[0] + if _JAVA_DIR: + return _JAVA_DIR[0] + + jdk_dest_dir = runtime.build_path('jdk4test') + if os.path.exists(os.path.join(jdk_dest_dir, "bin", "java")): + _JAVA_DIR.append(jdk_dest_dir) + return jdk_dest_dir + + # Get jdk with the lowest version + jdk_tar_version = None + jdk_tar_path = None + for name in os.listdir(jdk_dir): + m = _JDK_RE.match(name) + if m: + v = int(m.group(1)) + if jdk_tar_version is None or jdk_tar_version > v: + jdk_tar_version = v + jdk_tar_path = os.path.join(jdk_dir, name) + + if jdk_tar_path is None: + _JAVA_DIR.append(None) + return None + + with contextlib.closing(tarfile.open(jdk_tar_path)) as tf: + tf.extractall(jdk_dest_dir) + assert os.path.exists(os.path.join(jdk_dest_dir, "bin", "java")) + _JAVA_DIR.append(jdk_dest_dir) + return jdk_dest_dir |