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
6 changes: 5 additions & 1 deletion llvm/utils/lit/lit/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,8 @@ def executeScriptInternal(
results = []
timeoutInfo = None
shenv = ShellEnvironment(cwd, test.config.environment)
shenv.env["LIT_CURRENT_TESTCASE"] = test.getFullName()

exitCode, timeoutInfo = executeShCmd(
cmd, shenv, results, timeout=litConfig.maxIndividualTestTime
)
Expand Down Expand Up @@ -1425,11 +1427,13 @@ def executeScript(test, litConfig, tmpBase, commands, cwd):
# run on clang with no real loss.
command = litConfig.valgrindArgs + command

env = dict(test.config.environment)
env["LIT_CURRENT_TESTCASE"] = test.getFullName()
try:
out, err, exitCode = lit.util.executeCommand(
command,
cwd=cwd,
env=test.config.environment,
env=env,
timeout=litConfig.maxIndividualTestTime,
)
return (out, err, exitCode, None)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Tests that the LIT_CURRENT_TESTCASE variable is set to the name of the currently executing testcase

## Check default environment.
# RUN: bash -c 'echo $LIT_CURRENT_TESTCASE' | FileCheck --match-full-lines %s
#
# CHECK: shtest-env :: env-current-testcase.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Tests the env command in various scenarios: without arguments, setting, unsetting, and mixing envrionment variables.
# FIXME: All of these tests are broken and will not even call FileCheck.

## Check default environment.
# RUN: env | FileCheck -check-prefix=NO-ARGS %s
Expand Down
11 changes: 8 additions & 3 deletions llvm/utils/lit/tests/shtest-env-positive.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Test the env command's successful executions.

# CHECK: -- Testing: 10 tests{{.*}}
# CHECK: -- Testing: 11 tests{{.*}}

# CHECK: PASS: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
# CHECK: env FOO=1
Expand Down Expand Up @@ -39,6 +39,11 @@
# CHECK-NOT: # error:
# CHECK: --

# CHECK: PASS: shtest-env :: env-current-testcase.txt ({{[^)]*}})
# CHECK: # executed command: bash -c 'echo $LIT_CURRENT_TESTCASE'
# CHECK-NOT: # error:
# CHECK: --

# CHECK: PASS: shtest-env :: env-i.txt ({{[^)]*}})
# CHECK: env -i | {{.*}}
# CHECK: # executed command: env -i
Expand Down Expand Up @@ -71,6 +76,6 @@
# CHECK-NOT: # error:
# CHECK: --

# CHECK: Total Discovered Tests: 10
# CHECK: Passed: 10 {{\([0-9]*\.[0-9]*%\)}}
# CHECK: Total Discovered Tests: 11
# CHECK: Passed: 11 {{\([0-9]*\.[0-9]*%\)}}
# CHECK-NOT: {{.}}