aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakhropov <akhropov@yandex-team.com>2024-07-24 18:54:29 +0300
committerakhropov <akhropov@yandex-team.com>2024-07-24 19:07:13 +0300
commitb935fd3c34569828f2ae73eb31a6ac843e2e3023 (patch)
tree99d16b5dc8982fd6097166fffb3ef3d2079c88d7
parent26c7dd4c0a191212c8c46d37a93d5844bb6aa7bd (diff)
downloadydb-b935fd3c34569828f2ae73eb31a6ac843e2e3023.tar.gz
Workaround to fix split_unittest.py on Windows.
b590ca5fca91b744ffa85f8ef555564ea54d6cd6
-rw-r--r--build/export_generators/cmake/build/scripts/split_unittest.py10
-rw-r--r--build/export_generators/hardcoded-cmake/build/scripts/split_unittest.py10
-rw-r--r--build/scripts/split_unittest.py10
3 files changed, 21 insertions, 9 deletions
diff --git a/build/export_generators/cmake/build/scripts/split_unittest.py b/build/export_generators/cmake/build/scripts/split_unittest.py
index 8874b8b915..7214c70fdc 100644
--- a/build/export_generators/cmake/build/scripts/split_unittest.py
+++ b/build/export_generators/cmake/build/scripts/split_unittest.py
@@ -1,4 +1,5 @@
import argparse
+import os
import tempfile
import shlex
import subprocess
@@ -31,11 +32,14 @@ def get_shuffled_chunk(tests, modulo, modulo_index):
def list_tests(binary):
- with tempfile.NamedTemporaryFile() as tmpfile:
- cmd = [binary, "--list-verbose", "--list-path", tmpfile.name]
+ # can't use NamedTemporaryFile or mkstemp because of child process access issues on Windows
+ # https://stackoverflow.com/questions/66744497/python-tempfile-namedtemporaryfile-cant-use-generated-tempfile
+ with tempfile.TemporaryDirectory() as tmp_dir:
+ list_file = os.path.join(tmp_dir, 'list')
+ cmd = [binary, "--list-verbose", "--list-path", list_file]
subprocess.check_call(cmd)
- with open(tmpfile.name) as afile:
+ with open(list_file) as afile:
lines = afile.read().strip().split("\n")
lines = [x.strip() for x in lines]
return [x for x in lines if x]
diff --git a/build/export_generators/hardcoded-cmake/build/scripts/split_unittest.py b/build/export_generators/hardcoded-cmake/build/scripts/split_unittest.py
index 8874b8b915..7214c70fdc 100644
--- a/build/export_generators/hardcoded-cmake/build/scripts/split_unittest.py
+++ b/build/export_generators/hardcoded-cmake/build/scripts/split_unittest.py
@@ -1,4 +1,5 @@
import argparse
+import os
import tempfile
import shlex
import subprocess
@@ -31,11 +32,14 @@ def get_shuffled_chunk(tests, modulo, modulo_index):
def list_tests(binary):
- with tempfile.NamedTemporaryFile() as tmpfile:
- cmd = [binary, "--list-verbose", "--list-path", tmpfile.name]
+ # can't use NamedTemporaryFile or mkstemp because of child process access issues on Windows
+ # https://stackoverflow.com/questions/66744497/python-tempfile-namedtemporaryfile-cant-use-generated-tempfile
+ with tempfile.TemporaryDirectory() as tmp_dir:
+ list_file = os.path.join(tmp_dir, 'list')
+ cmd = [binary, "--list-verbose", "--list-path", list_file]
subprocess.check_call(cmd)
- with open(tmpfile.name) as afile:
+ with open(list_file) as afile:
lines = afile.read().strip().split("\n")
lines = [x.strip() for x in lines]
return [x for x in lines if x]
diff --git a/build/scripts/split_unittest.py b/build/scripts/split_unittest.py
index 8874b8b915..7214c70fdc 100644
--- a/build/scripts/split_unittest.py
+++ b/build/scripts/split_unittest.py
@@ -1,4 +1,5 @@
import argparse
+import os
import tempfile
import shlex
import subprocess
@@ -31,11 +32,14 @@ def get_shuffled_chunk(tests, modulo, modulo_index):
def list_tests(binary):
- with tempfile.NamedTemporaryFile() as tmpfile:
- cmd = [binary, "--list-verbose", "--list-path", tmpfile.name]
+ # can't use NamedTemporaryFile or mkstemp because of child process access issues on Windows
+ # https://stackoverflow.com/questions/66744497/python-tempfile-namedtemporaryfile-cant-use-generated-tempfile
+ with tempfile.TemporaryDirectory() as tmp_dir:
+ list_file = os.path.join(tmp_dir, 'list')
+ cmd = [binary, "--list-verbose", "--list-path", list_file]
subprocess.check_call(cmd)
- with open(tmpfile.name) as afile:
+ with open(list_file) as afile:
lines = afile.read().strip().split("\n")
lines = [x.strip() for x in lines]
return [x for x in lines if x]