This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] [test] Pass some windows environment variables through to test processes
ClosedPublic

Authored by mstorsjo on Feb 25 2021, 12:56 AM.

Details

Summary

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 f1a96de1bc8db527b5eb820c36c17e275900ca2b, 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.

Diff Detail

Event Timeline

mstorsjo created this revision.Feb 25 2021, 12:56 AM
mstorsjo requested review of this revision.Feb 25 2021, 12:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2021, 12:56 AM
Herald added 1 blocking reviewer(s): Restricted Project. · View Herald Transcript
curdeius accepted this revision.Feb 25 2021, 4:20 AM
curdeius added a subscriber: curdeius.

LGTM. But I believe that the long term solution is to run all the tests in the internal lit shell.

LGTM. But I believe that the long term solution is to run all the tests in the internal lit shell.

Yes, but I believe that aspect is orthogonal to this script. Currently the lit test driver runs the test script (which consists of two lines, one "clang++" to compile the test and one which invokes the run.py script with python to execute the built test executable) with bash, which maybe could/should be changed to use the lit internal shell. That still keeps the run.py wrapper script for all the purposes it serves right now (codesign, setting up other test specific env variables etc).

ldionne requested changes to this revision.Mar 2 2021, 9:38 AM
ldionne added a subscriber: ldionne.

LGTM. But I believe that the long term solution is to run all the tests in the internal lit shell.

Yes, but I believe that aspect is orthogonal to this script. Currently the lit test driver runs the test script (which consists of two lines, one "clang++" to compile the test and one which invokes the run.py script with python to execute the built test executable) with bash, which maybe could/should be changed to use the lit internal shell. That still keeps the run.py wrapper script for all the purposes it serves right now (codesign, setting up other test specific env variables etc).

Yes, that's correct.

I think it's pretty important to keep run.py and the other executors free of logic. Instead, we could string those environment variables into self.exec_env in config.py. They would then be passed to the executor using the --env argument, which was meant for that. WDYT?

This revision now requires changes to proceed.Mar 2 2021, 9:38 AM

LGTM. But I believe that the long term solution is to run all the tests in the internal lit shell.

Yes, but I believe that aspect is orthogonal to this script. Currently the lit test driver runs the test script (which consists of two lines, one "clang++" to compile the test and one which invokes the run.py script with python to execute the built test executable) with bash, which maybe could/should be changed to use the lit internal shell. That still keeps the run.py wrapper script for all the purposes it serves right now (codesign, setting up other test specific env variables etc).

Yes, that's correct.

I think it's pretty important to keep run.py and the other executors free of logic. Instead, we could string those environment variables into self.exec_env in config.py. They would then be passed to the executor using the --env argument, which was meant for that. WDYT?

Sure - maybe.

However, I see it as a bit of different concern about passing specific options requested from config.py, vs allowing some vars through transparently.

Consider cross testing (I do that, but that's further away in the upstreaming pipeline) - I don't want to pick up env vars blindly from the (unix) build env and pass them to the remote runner (windows), I just want the logic that creates a clean env to let some specifics through.

Those setups use a variant of the existing ssh.py runner (which don't clear the env, only add vars to it), while run.py (for local execution) is the one that entirely wipe the env before adding the env vars that are requested.

ldionne accepted this revision.Mar 2 2021, 12:25 PM

[...]

Consider cross testing (I do that, but that's further away in the upstreaming pipeline) - I don't want to pick up env vars blindly from the (unix) build env and pass them to the remote runner (windows), I just want the logic that creates a clean env to let some specifics through.

Those setups use a variant of the existing ssh.py runner (which don't clear the env, only add vars to it), while run.py (for local execution) is the one that entirely wipe the env before adding the env vars that are requested.

I'm convinced. Indeed, it doesn't make any sense to forward env vars from the build host to the run host.

This revision is now accepted and ready to land.Mar 2 2021, 12:25 PM