diff options
author | alevitskii <alevitskii@yandex-team.com> | 2024-08-26 08:38:55 +0300 |
---|---|---|
committer | alevitskii <alevitskii@yandex-team.com> | 2024-08-26 08:52:09 +0300 |
commit | 9cd5c4ca8b08287c6c01762a11f5ce5ad87d39eb (patch) | |
tree | 09de537af870db1b21bfe3056e2f6e3e9ab63ef4 /build/scripts/run_junit.py | |
parent | cdaed5bc46df016c0a8b33995a60a016aa1e1d35 (diff) | |
download | ydb-9cd5c4ca8b08287c6c01762a11f5ce5ad87d39eb.tar.gz |
Set ram drive path in junit scripts
Set ram drive path in scripts
a9a79267f4e34aff3b96e3147b646e474adf24a1
Diffstat (limited to 'build/scripts/run_junit.py')
-rw-r--r-- | build/scripts/run_junit.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/build/scripts/run_junit.py b/build/scripts/run_junit.py index e6384d7929..380d25e6a7 100644 --- a/build/scripts/run_junit.py +++ b/build/scripts/run_junit.py @@ -1,3 +1,4 @@ +import json import os import sys @@ -12,6 +13,30 @@ def on_shutdown(s, f): raise SignalInterruptionError() +def mkdir_p(directory): + if not os.path.exists(directory): + os.makedirs(directory) + + +def _resolve_tmpdir_to_ram_drive_path(args): + java_io_tmpdir_arg = '-Djava.io.tmpdir=' + for i, arg in enumerate(args): + if arg.startswith(java_io_tmpdir_arg) and arg.split('=')[-1] == "${YA_TEST_JAVA_TMP_DIR}": + try: + with open(os.environ['YA_TEST_CONTEXT_FILE']) as afile: + context = json.load(afile) + ram_tmpdir = context['runtime']['ram_drive_path'] + except Exception as e: + ram_tmpdir = os.path.join(os.getcwd(), 'tests_tmp_dir') + msg = "Warning: temp dir on ram drive was requested but ram drive path couldn't be obtained " + msg += 'from context file due to error {!r}. '.format(e) + msg += 'Temp dir in cwd will be used instead: {}\n'.format(ram_tmpdir) + sys.stderr.write(msg) + mkdir_p(ram_tmpdir) + args[i] = java_io_tmpdir_arg + ram_tmpdir + return + + def main(): args = sys.argv[1:] @@ -22,6 +47,8 @@ def main(): java_bin_dir = os.path.dirname(jar_binary) jstack_binary = os.path.join(java_bin_dir, 'jstack.exe' if sys.platform == 'win32' else 'jstack') + _resolve_tmpdir_to_ram_drive_path(args) + if not os.path.exists(jstack_binary): sys.stderr.write("jstack is missing: {}\n".format(jstack_binary)) execve() |