[PATCH] D65624: [lit] Print internal env commands

Joel E. Denny via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 1 17:25:21 PDT 2019


jdenny created this revision.
jdenny added reviewers: probinson, stella.stamenova, bd1976llvm, jlpeyton, rnk, mgorny.
Herald added a subscriber: delcypher.
Herald added a project: LLVM.

The internal `env` command removes `env` and its args from the command
line while parsing it.  This restores them before printing the command
line.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65624

Files:
  llvm/utils/lit/lit/TestRunner.py
  llvm/utils/lit/tests/shtest-env.py


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
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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65624.212939.patch
Type: text/x-patch
Size: 2114 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190802/6df654cb/attachment.bin>


More information about the llvm-commits mailing list