Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions llvm/utils/lit/lit/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,10 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
not_args = []
not_count = 0
not_crash = False

# Expand all late substitutions.
args = _expandLateSubstitutions(j, args, cmd_shenv.cwd)

while True:
if args[0] == "env":
# Create a copy of the global environment and modify it for
Expand Down Expand Up @@ -875,9 +879,6 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
# Ensure args[0] is hashable.
args[0] = expand_glob(args[0], cmd_shenv.cwd)[0]

# Expand all late substitutions.
args = _expandLateSubstitutions(j, args, cmd_shenv.cwd)

inproc_builtin = inproc_builtins.get(args[0], None)
if inproc_builtin and (args[0] != "echo" or len(cmd.commands) == 1):
# env calling an in-process builtin is useless, so we take the safe
Expand Down
6 changes: 6 additions & 0 deletions llvm/utils/lit/tests/Inputs/shtest-readfile/env.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Tests that readfile works with the env builtin.
# RUN: echo -n "hello" > %t.1
# RUN: env TEST=%{readfile:%t.1} %{python} -c "import os; print(os.environ['TEST'])"

## Fail the test so we can assert on the output.
# RUN: not echo return
1 change: 1 addition & 0 deletions llvm/utils/lit/tests/Inputs/shtest-readfile/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use_lit_shell = lit.util.pythonize_bool(lit_shell_env)
config.test_format = lit.formats.ShTest(execute_external=not use_lit_shell)
config.test_source_root = None
config.test_exec_root = None
config.substitutions.append(("%{python}", '"%s"' % (sys.executable)))

# If we are testing with the external shell, remove the fake-externals from
# PATH so that we use mkdir in the tests.
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/lit/tests/shtest-readfile-external.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# UNSUPPORTED: system-windows
# RUN: env LIT_USE_INTERNAL_SHELL=0 not %{lit} -a -v %{inputs}/shtest-readfile | FileCheck -match-full-lines -DTEMP_PATH=%S/Inputs/shtest-readfile/Output %s

# CHECK: -- Testing: 4 tests{{.*}}
# CHECK: -- Testing: 5 tests{{.*}}

# CHECK-LABEL: FAIL: shtest-readfile :: absolute-paths.txt ({{[^)]*}})
# CHECK: echo $(cat [[TEMP_PATH]]/absolute-paths.txt.tmp) && test -e [[TEMP_PATH]]/absolute-paths.txt.tmp {{.*}}
Expand Down
6 changes: 5 additions & 1 deletion llvm/utils/lit/tests/shtest-readfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@

# RUN: env LIT_USE_INTERNAL_SHELL=1 not %{lit} -a -v %{inputs}/shtest-readfile | FileCheck -match-full-lines -DTEMP_PATH=%S%{fs-sep}Inputs%{fs-sep}shtest-readfile%{fs-sep}Output %s

# CHECK: -- Testing: 4 tests{{.*}}
# CHECK: -- Testing: 5 tests{{.*}}

# CHECK-LABEL: FAIL: shtest-readfile :: absolute-paths.txt ({{[^)]*}})
# CHECK: echo hello
# CHECK: # executed command: echo '%{readfile:[[TEMP_PATH]]{{[\\\/]}}absolute-paths.txt.tmp}'

# CHECK-LABEL: FAIL: shtest-readfile :: env.txt ({{[^)]*}})
# CHECK: env TEST=hello {{.*}} -c "import os; print(os.environ['TEST'])"
# CHECK: # | hello

# CHECK-LABEL: FAIL: shtest-readfile :: file-does-not-exist.txt ({{[^)]*}})
# CHECK: # executed command: @echo 'echo %{readfile:/file/does/not/exist}'
# CHECK: # | File specified in readfile substitution does not exist: {{.*}}/file/does/not/exist
Expand Down