Skip to content

Commit 34ee3d9

Browse files
committed
[libcxx] [test] Pass some windows environment variables through to test processes
Normally, the run.py wrapper script runs the child processes in a clean environment, with only the environment variables available that are passed via the --env parameter. However, the COMSPEC and TEMP variables are kind of necessary when running some tests; COMSPEC is necessary for finding the interpreter when executing commands via std::system(). Before f1a96de, tests were executed via an intermediate shell which implicitly readded the COMSPEC variable. The TEMP variable allows temp files to be placed in a sensible location; if unset, they're placed in the default temp fallback of C:\Windows instead. Differential Revision: https://reviews.llvm.org/D97452
1 parent c5e8f02 commit 34ee3d9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

libcxx/utils/run.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
"""
1515

1616
import argparse
17+
import os
18+
import platform
1719
import subprocess
1820
import sys
1921

@@ -37,6 +39,14 @@ def main():
3739

3840
# Extract environment variables into a dictionary
3941
env = {k : v for (k, v) in map(lambda s: s.split('=', 1), args.env)}
42+
if platform.system() == 'Windows':
43+
# Pass some extra variables through on Windows:
44+
# COMSPEC is needed for running subprocesses via std::system().
45+
if 'COMSPEC' in os.environ:
46+
env['COMSPEC'] = os.environ.get('COMSPEC')
47+
# TEMP is needed for placing temp files in a sensible directory.
48+
if 'TEMP' in os.environ:
49+
env['TEMP'] = os.environ.get('TEMP')
4050

4151
# Run the command line with the given environment in the execution directory.
4252
return subprocess.call(commandLine, cwd=args.execdir, env=env, shell=False)

0 commit comments

Comments
 (0)