-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[lit] Add LIT_CURRENT_TESTCASE environment variable when running tests #168762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-testing-tools Author: Andrew Haberlandt (ndrewh) ChangesI'm not aware of any way for This adds the Full diff: https://github.com/llvm/llvm-project/pull/168762.diff 1 Files Affected:
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 64148c6098327..9525320f133c6 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -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
)
@@ -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)
|
boomanaiden154
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a reasonable enough feature to me for the stated use case.
It would be good if this had a test though, at least for the internal shell.
🐧 Linux x64 Test Results
|
|
@boomanaiden154 I added a testcase. Apparently |
Yeah, that's a known issue with how we handle builtins in lit. It's on my TODO list to fix, but hasn't been super high priority. Bash in this case seems fine to me. |
boomanaiden154
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the tests.
No idea if this would work, but could you do |
I still don't think that works. The issue is that env is executed as a builtin and doesn't have support for writing to the |
llvm#168762) I'm not aware of any way for `%run` wrapper scripts like `iosssim_run.py` ([ref](https://github.com/llvm/llvm-project/blob/d2c7c6064259320def7a74e111079725958697d4/compiler-rt/test/sanitizer_common/ios_commands/iossim_run.py#L4)) to know what testcase they are currently running. This can be useful if these wrappers need to create a (potentially remote) temporary directory for each test case. This adds the `LIT_CURRENT_TESTCASE` environment variable to both the internal shell and the external shell, containing the full name of the current test being run. (cherry picked from commit 3f6cbde)
I'm not aware of any way for
%runwrapper scripts likeiosssim_run.py(ref) to know what testcase they are currently running. This can be useful if these wrappers need to create a (potentially remote) temporary directory for each test case.This adds the
LIT_CURRENT_TESTCASEenvironment variable to both the internal shell and the external shell, containing the full name of the current test being run.