diff options
author | robot-piglet <[email protected]> | 2025-09-18 11:59:31 +0300 |
---|---|---|
committer | robot-piglet <[email protected]> | 2025-09-18 12:17:20 +0300 |
commit | e2dc5e15bc02bff63e44ed9c74ff1093d87d845b (patch) | |
tree | edd3015ae492064effbe48767a36f53ca23f6710 /yql/essentials/tests | |
parent | d2d6681538770d0c2725615373a6c2e07adf653e (diff) |
Intermediate changes
commit_hash:1bb058fdc353cb6abf7a9f65e8c1a61a424274f3
Diffstat (limited to 'yql/essentials/tests')
-rw-r--r-- | yql/essentials/tests/common/test_framework/yqlrun.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/yql/essentials/tests/common/test_framework/yqlrun.py b/yql/essentials/tests/common/test_framework/yqlrun.py index fdf5110f5f3..5629875a8ef 100644 --- a/yql/essentials/tests/common/test_framework/yqlrun.py +++ b/yql/essentials/tests/common/test_framework/yqlrun.py @@ -1,3 +1,4 @@ +import errno import os import shutil import yatest.common @@ -23,6 +24,25 @@ FIX_DIR_PREFIXES = { } +def safe_symlink(src, dst): + """ + If dst is an existing directory, creates a symlink inside it with the basename of src. + If dst is a file path (does not exist or is not a directory), creates the symlink at dst. + If the link already exists, does nothing. + """ + # If dst is an existing directory, append basename of src + if os.path.isdir(dst): + link_path = os.path.join(dst, os.path.basename(src)) + else: + link_path = dst + + try: + os.symlink(src, link_path) + except OSError as e: + if e.errno != errno.EEXIST: + raise + + class YQLRun(object): def __init__(self, udfs_dir=None, prov='yt', use_sql2yql=False, keep_temp=True, binary=None, gateway_config=None, @@ -210,7 +230,7 @@ class YQLRun(object): copy_dest = os.path.join(res_dir, f) if not os.path.exists(os.path.dirname(copy_dest)): os.makedirs(os.path.dirname(copy_dest)) - shutil.copy2( + safe_symlink( real_path, copy_dest, ) @@ -232,9 +252,9 @@ class YQLRun(object): else: copy_dest = res_dir files[f] = os.path.basename(files[f]) - shutil.copy2(path_to_copy, copy_dest) + safe_symlink(path_to_copy, copy_dest) else: - shutil.copy2(files[f], res_dir) + safe_symlink(files[f], res_dir) files[f] = os.path.basename(files[f]) cmd += yql_utils.get_cmd_for_files('--file', files) |