Skip to content

Commit 407b50b

Browse files
committed
Pass tests to subprocess through a file
1 parent 091ec2a commit 407b50b

File tree

1 file changed

+24
-5
lines changed
  • graalpython/com.oracle.graal.python.test/src

1 file changed

+24
-5
lines changed

graalpython/com.oracle.graal.python.test/src/runner.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,17 +507,30 @@ def process_event(self, event, out_file):
507507

508508
def run_in_subprocess_and_watch(self, tests: list[TestId]):
509509
conn, child_conn = multiprocessing.Pipe()
510-
with tempfile.NamedTemporaryFile(prefix='graalpytest-out-', mode='w+') as out_file:
510+
with (
511+
tempfile.NamedTemporaryFile(prefix='graalpytest-in-', mode='w+') as tests_file,
512+
tempfile.NamedTemporaryFile(prefix='graalpytest-out-', mode='w+') as out_file,
513+
):
511514
env = os.environ.copy()
512515
env['IN_PROCESS'] = '1'
513516
remaining_tests = tests
514517
while remaining_tests and not self.stop_event.is_set():
515518
self.last_out_pos = out_file.tell()
516519
python_args = ['-u', *self.subprocess_args]
517-
cmd = [sys.executable, *python_args, __file__, '--pipe-fd', str(child_conn.fileno())]
520+
cmd = [
521+
sys.executable,
522+
*python_args,
523+
__file__,
524+
'--pipe-fd', str(child_conn.fileno()),
525+
'--tests-file', tests_file.name,
526+
]
518527
if self.failfast:
519528
cmd.append('--failfast')
520-
cmd += [str(s) for s in remaining_tests]
529+
# We communicate the tests through a temp file to avoid running into too long commandlines on windows
530+
tests_file.seek(0)
531+
tests_file.truncate()
532+
tests_file.write('\n'.join(map(str, remaining_tests)))
533+
tests_file.flush()
521534
process = subprocess.Popen(
522535
cmd,
523536
stdout=out_file,
@@ -778,11 +791,17 @@ def loadTestsFromModule(self, module, *, pattern=None):
778791
def in_process():
779792
parser = argparse.ArgumentParser()
780793
parser.add_argument('--pipe-fd', type=int, required=True)
794+
parser.add_argument('--tests-file', type=Path, required=True)
781795
parser.add_argument('--failfast', action='store_true')
782-
parser.add_argument('tests', nargs='*', type=TestSpecifier.from_str)
783796
args = parser.parse_args()
797+
tests = []
798+
with open(args.tests_file) as f:
799+
for line in f:
800+
tests.append(TestSpecifier.from_str(line.strip()))
801+
784802
conn = multiprocessing.connection.Connection(args.pipe_fd)
785-
for test_suite in collect(args.tests):
803+
804+
for test_suite in collect(tests):
786805
result = PipeResult(test_suite, conn)
787806
result.failfast = args.failfast
788807
test_suite.run(result)

0 commit comments

Comments
 (0)