Index: llvm/utils/lit/lit/TestRunner.py =================================================================== --- llvm/utils/lit/lit/TestRunner.py +++ llvm/utils/lit/lit/TestRunner.py @@ -872,6 +872,7 @@ for i,j in enumerate(cmd.commands): # Reference the global environment by default. cmd_shenv = shenv + original_args = list(j.args) if j.args[0] == 'env': # Create a copy of the global environment and modify it for this one # command. There might be multiple envs in a pipeline: @@ -965,6 +966,9 @@ else: default_stdin = subprocess.PIPE + # Restore the original args for printing. + cmd.commands[i].args = original_args + # Explicitly close any redirected files. We need to do this now because we # need to release any handles we may have on the temporary files (important # on Win32, for example). Since we have already spawned the subprocess, our Index: llvm/utils/lit/tests/shtest-env.py =================================================================== --- llvm/utils/lit/tests/shtest-env.py +++ llvm/utils/lit/tests/shtest-env.py @@ -1,3 +1,23 @@ # Check the env command # -# RUN: %{lit} -a -v %{inputs}/shtest-env +# RUN: %{lit} -j 1 -a -v %{inputs}/shtest-env \ +# RUN: | FileCheck -match-full-lines %s +# +# END. + +# Make sure env commands are included in printed commands. + +# CHECK: PASS: shtest-env :: env-u.txt ({{[^)]*}}) +# CHECK: $ "{{[^"]*}}" "print_environment.py" +# CHECK: $ "env" "-u" "FOO" "{{[^"]*}}" "print_environment.py" +# CHECK: $ "env" "-u" "FOO" "-u" "BAR" "{{[^"]*}}" "print_environment.py" + +# CHECK: PASS: shtest-env :: env.txt ({{[^)]*}}) +# CHECK: $ "env" "A_FOO=999" "{{[^"]*}}" "print_environment.py" +# CHECK: $ "env" "A_FOO=1" "B_BAR=2" "C_OOF=3" "{{[^"]*}}" "print_environment.py" + +# CHECK: PASS: shtest-env :: mixed.txt ({{[^)]*}}) +# CHECK: $ "env" "A_FOO=999" "-u" "FOO" "{{[^"]*}}" "print_environment.py" +# CHECK: $ "env" "A_FOO=1" "-u" "FOO" "B_BAR=2" "-u" "BAR" "C_OOF=3" "{{[^"]*}}" "print_environment.py" + +# CHECK: Expected Passes : 3