Skip to content

Commit

Permalink
Rework how test processes are called on Windows
Browse files Browse the repository at this point in the history
This changes how runSubprocess works on Windows to insert all of the
calls within a temporary bash script. This ensures that the entire
environment is available when running the processes, which doesn't
work when simply calling subprocess.check_call().
  • Loading branch information
timwoj committed Dec 12, 2022
1 parent aaaee10 commit 3331fec
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion btest
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,17 @@ def runTestCommandLine(cmdline, measure_time, **kwargs):
def runSubprocess(*args, **kwargs):
def child(q):
try:
subprocess.check_call(*args, **kwargs)
if sys.platform == 'win32':
tmpdir = normalize_path(kwargs.get('cwd', ''))
tf, tf_name = tempfile.mkstemp(suffix='.sh', dir=tmpdir)
fcontents = f'#!/usr/bin/env bash\n{" ".join(args)}\n'
with os.fdopen(tf, 'wb') as f:
f.write(fcontents.encode('utf-8'))

cmd = ['bash.exe', '-c', normalize_path(tf_name)]
subprocess.check_call(cmd, **kwargs)
else:
subprocess.check_call(*args, **kwargs)
success = True
rc = 0

Expand Down

0 comments on commit 3331fec

Please sign in to comment.