From 3331fec02df1d6bd0ee96dcb2bf946b5e4e31508 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Thu, 8 Dec 2022 13:30:59 -0700 Subject: [PATCH] Rework how test processes are called on Windows 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(). --- btest | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/btest b/btest index 15098eb5..d4799ce5 100755 --- a/btest +++ b/btest @@ -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