-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[llvm-lit] Print environment variables when using env without subcommand #98414
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
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
bd4f897
[llvm-lit]
Harini0924 a44f93b
[llvm-lit] Resolve env subcommand required error
Harini0924 cded1a6
[llvm-lit] Resolve env subcommand required error
Harini0924 94d958a
hi
Harini0924 e359516
[llvm-lit] Resolve env subcommand required error
Harini0924 3a9a919
[llvm-lit] Resolve env subcommand required error
Harini0924 4990d39
[llvm-lit] Resolve env subcommand required error
Harini0924 37cbf4f
[llvm-lit] Using a commit ID that passes all test cases
Harini0924 06d2481
[llvm-lit] Formatting Python files
Harini0924 964cc30
Resolved conflicts and added changes to env-args-none.txt, lit.cfg, a…
Harini0924 6a2dbe5
Merge branch 'llvm:main' into llvm_env
Harini0924 d6a37da
[llvm-lit] Add pattern to CHECK lines for env command
Harini0924 ac03f43
[llvm-lit] Used darker to format the python files
Harini0924 4fe54d4
[llvm-lit] Added a space in env-args-none.txt
Harini0924 fcec361
[llvm-lit] Updated shtest-env.py for Consistent Output Checking
Harini0924 957c7a6
[llvm-lit] Modified `CHECK-NOT: {{^[^#]}}`
Harini0924 b18939e
[llvm-lit] Split shtest-env tests into separate positive and negative…
Harini0924 8c0168a
[llvm-lit] Remove shtest-env files after restructuring
Harini0924 a6dc004
[llvm-lit] Removed `print_environment.py` file and Refactored some tests
Harini0924 053e7eb
[llvm-lit] Improved comments
Harini0924 61f2bf9
Updated the comments in files modified
Harini0924 69809a6
Fixed trailing space.
Harini0924 070ccde
Renamed env-args-none.txt to env-no-subcommand.txt and alphabetized t…
Harini0924 7e2be8b
Fixed trailing whitespaces and `# CHECK: --` which I accidentally rem…
Harini0924 4406d4b
Merge branch 'main' into llvm_env
Harini0924 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions
32
llvm/utils/lit/tests/Inputs/shtest-env-positive/env-calls-env.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
## Tests the behaviour of chaining env commands together. | ||
|
||
## Check that internal env can call internal env. | ||
# RUN: env env | FileCheck -check-prefix=CHECK-2-EMPTY-ARGS %s | ||
# | ||
# CHECK-2-EMPTY-ARGS: BAR = 2 | ||
# CHECK-2-EMPTY-ARGS: FOO = 1 | ||
|
||
## Check setting variables in a nested env call. | ||
# RUN: env FOO=2 env BAR=1 | FileCheck -check-prefix=CHECK-2-VAL %s | ||
# | ||
# CHECK-2-VAL: BAR = 1 | ||
# CHECK-2-VAL: FOO = 2 | ||
|
||
## Check unsetting variables in a nested env call. | ||
# RUN: env -u FOO env -u BAR | FileCheck -check-prefix=CHECK-2-U %s | ||
# | ||
# CHECK-2-U-NOT: BAR | ||
# CHECK-2-U-NOT: FOO | ||
|
||
## Check mixed setting and unsetting in nested env calls. | ||
# RUN: env -u FOO BAR=1 env -u BAR FOO=2 | FileCheck -check-prefix=CHECK-2-U-VAL %s | ||
# | ||
# CHECK-2-U-VAL-NOT: BAR | ||
# CHECK-2-U-VAL: FOO = 2 | ||
|
||
## Check setting, unsetting, and adding a new variable in nested env calls. | ||
# RUN: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 | FileCheck -check-prefix=CHECK-3 %s | ||
# | ||
# CHECK-3-NOT: BAR | ||
# CHECK-3: BAZ = 3 | ||
# CHECK-3: FOO = 2 |
37 changes: 37 additions & 0 deletions
37
llvm/utils/lit/tests/Inputs/shtest-env-positive/env-no-subcommand.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
## Tests the env command in various scenarios: without arguments, setting, unsetting, and mixing envrionment variables. | ||
|
||
## Check default environment. | ||
# RUN: env | FileCheck -check-prefix=NO-ARGS %s | ||
# | ||
# NO-ARGS: BAR=2 | ||
# NO-ARGS: FOO=1 | ||
# NO-ARGS: QUX=3 | ||
|
||
## Set environment variables. | ||
# RUN: env FOO=2 BAR=1 | FileCheck -check-prefix=SET-VAL %s | ||
# | ||
# SET-VAL: BAR=1 | ||
# SET-VAL: FOO=2 | ||
# SET-VAL: QUX=3 | ||
|
||
## Unset environment variables. | ||
# RUN: env -u FOO -u BAR | FileCheck -check-prefix=UNSET-U %s | ||
# | ||
# UNSET-U-NOT: BAR | ||
# UNSET-U-NOT: FOO | ||
# UNSET-U: QUX=3 | ||
|
||
## Mixed set and unset environment variables. | ||
# RUN: env -u FOO BAR=1 -u BAR FOO=2 | FileCheck -check-prefix=MIXED-SET-UNSET %s | ||
# | ||
# MIXED-SET-UNSET-NOT: BAR | ||
# MIXED-SET-UNSET: FOO=2 | ||
# MIXED-SET-UNSET: QUX=3 | ||
|
||
## Mixed set and unset with additional variable. | ||
# RUN: env -u FOO BAR=1 -u BAR FOO=2 BAZ=4 | FileCheck -check-prefix=MIXED-SET-UNSET-ADD-3 %s | ||
# | ||
# MIXED-SET-UNSET-ADD-NOT: BAR | ||
# MIXED-SET-UNSET-ADD: BAZ=4 | ||
# MIXED-SET-UNSET-ADD: FOO=2 | ||
# MIXED-SET-UNSET-ADD: QUX=3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
## Tests env command for preset variables and handling single/multiple unsets. | ||
|
||
## Check and make sure preset environment variable were set in lit.cfg. | ||
# | ||
# RUN: env | FileCheck --check-prefix=CHECK-ENV-PRESET %s | ||
# | ||
## Check single unset of environment variable. | ||
# | ||
# RUN: env -u FOO | FileCheck --check-prefix=CHECK-ENV-UNSET-1 %s | ||
# | ||
## Check multiple unsets of environment variables. | ||
# | ||
# RUN: env -u FOO -u BAR | FileCheck --check-prefix=CHECK-ENV-UNSET-MULTIPLE %s | ||
|
||
# CHECK-ENV-PRESET: BAR = 2 | ||
# CHECK-ENV-PRESET: FOO = 1 | ||
|
||
# CHECK-ENV-UNSET-1: BAR = 2 | ||
# CHECK-ENV-UNSET-1-NOT: FOO | ||
|
||
# CHECK-ENV-UNSET-MULTIPLE-NOT: BAR | ||
# CHECK-ENV-UNSET-MULTIPLE-NOT: FOO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## Tests env command for setting single and multiple environment variables. | ||
|
||
## Check for simple one environment variable setting. | ||
# | ||
# RUN: env A_FOO=999 | FileCheck --check-prefix=CHECK-ENV-1 %s | ||
# | ||
## Check for multiple environment variable settings. | ||
# | ||
# RUN: env A_FOO=1 B_BAR=2 C_OOF=3 | FileCheck --check-prefix=CHECK-ENV-MULTIPLE %s | ||
|
||
# CHECK-ENV-1: A_FOO = 999 | ||
|
||
# CHECK-ENV-MULTIPLE: A_FOO = 1 | ||
# CHECK-ENV-MULTIPLE: B_BAR = 2 | ||
# CHECK-ENV-MULTIPLE: C_OOF = 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import lit.formats | ||
|
||
config.name = "shtest-env" | ||
config.suffixes = [".txt"] | ||
config.test_format = lit.formats.ShTest() | ||
config.test_source_root = None | ||
config.test_exec_root = None | ||
config.environment["FOO"] = "1" | ||
config.environment["BAR"] = "2" | ||
config.environment["QUX"] = "3" | ||
config.substitutions.append(("%{python}", '"%s"' % (sys.executable))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## Tests env command for setting and unsetting single and multiple environment variables. | ||
|
||
## Check for setting and removing one environment variable | ||
# | ||
# RUN: env A_FOO=999 -u FOO | FileCheck --check-prefix=CHECK-ENV-1 %s | ||
# | ||
## Check for setting/unsetting multiple environment variables | ||
# | ||
# RUN: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 | FileCheck --check-prefix=CHECK-ENV-MULTIPLE %s | ||
|
||
# CHECK-ENV-1: A_FOO = 999 | ||
# CHECK-ENV-1-NOT: FOO | ||
|
||
# CHECK-ENV-MULTIPLE: A_FOO = 1 | ||
# CHECK-ENV-MULTIPLE-NOT: BAR | ||
# CHECK-ENV-MULTIPLE: B_BAR = 2 | ||
# CHECK-ENV-MULTIPLE: C_OOF = 3 | ||
# CHECK-ENV-MULTIPLE-NOT: FOO |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
## Test the env command (failing tests). | ||
|
||
# RUN: not %{lit} -a -v %{inputs}/shtest-env-negative \ | ||
# RUN: | FileCheck -match-full-lines %s | ||
# | ||
# END. | ||
|
||
## Test the env command's expected failures. | ||
|
||
# CHECK: -- Testing: 7 tests{{.*}} | ||
|
||
# CHECK: FAIL: shtest-env :: env-calls-cd.txt ({{[^)]*}}) | ||
# CHECK: env -u FOO BAR=3 cd foobar | ||
# CHECK: # executed command: env -u FOO BAR=3 cd foobar | ||
# CHECK: # error: command failed with exit status: {{.*}} | ||
|
||
# CHECK: FAIL: shtest-env :: env-calls-colon.txt ({{[^)]*}}) | ||
# CHECK: env -u FOO BAR=3 : | ||
# CHECK: # executed command: env -u FOO BAR=3 : | ||
# CHECK: # error: command failed with exit status: {{.*}} | ||
|
||
# CHECK: FAIL: shtest-env :: env-calls-echo.txt ({{[^)]*}}) | ||
# CHECK: env -u FOO BAR=3 echo hello world | ||
# CHECK: # executed command: env -u FOO BAR=3 echo hello world | ||
# CHECK: # error: command failed with exit status: {{.*}} | ||
|
||
# CHECK: FAIL: shtest-env :: env-calls-export.txt ({{[^)]*}}) | ||
# CHECK: env -u FOO BAR=3 export BAZ=3 | ||
# CHECK: # executed command: env -u FOO BAR=3 export BAZ=3 | ||
# CHECK: # error: command failed with exit status: {{.*}} | ||
|
||
# CHECK: FAIL: shtest-env :: env-calls-mkdir.txt ({{[^)]*}}) | ||
# CHECK: env -u FOO BAR=3 mkdir foobar | ||
# CHECK: # executed command: env -u FOO BAR=3 mkdir foobar | ||
# CHECK: # error: command failed with exit status: {{.*}} | ||
|
||
# CHECK: FAIL: shtest-env :: env-calls-not-builtin.txt ({{[^)]*}}) | ||
# CHECK: env -u FOO BAR=3 not rm {{.+}}.no-such-file | ||
# CHECK: # executed command: env -u FOO BAR=3 not rm {{.+}}.no-such-file{{.*}} | ||
# CHECK: # error: command failed with exit status: {{.*}} | ||
|
||
# CHECK: FAIL: shtest-env :: env-calls-rm.txt ({{[^)]*}}) | ||
# CHECK: env -u FOO BAR=3 rm foobar | ||
# CHECK: # executed command: env -u FOO BAR=3 rm foobar | ||
# CHECK: # error: command failed with exit status: {{.*}} | ||
|
||
# CHECK: Total Discovered Tests: 7 | ||
# CHECK: Failed: 7 {{\([0-9]*\.[0-9]*%\)}} | ||
# CHECK-NOT: {{.}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
## Test the env command (passing tests). | ||
|
||
# RUN: %{lit} -a -v %{inputs}/shtest-env-positive \ | ||
# RUN: | FileCheck -match-full-lines %s | ||
# | ||
# END. | ||
|
||
## Test the env command's successful executions. | ||
|
||
# CHECK: -- Testing: 9 tests{{.*}} | ||
|
||
# CHECK: PASS: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}}) | ||
# CHECK: env FOO=1 | ||
# CHECK: # executed command: env FOO=1 | ||
# CHECK-NOT: # error: | ||
# CHECK: -- | ||
|
||
# CHECK: PASS: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}}) | ||
# CHECK: env -u FOO | ||
# CHECK: # executed command: env -u FOO | ||
# CHECK-NOT: # error: | ||
# CHECK: -- | ||
|
||
# CHECK: PASS: shtest-env :: env-args-last-is-u.txt ({{[^)]*}}) | ||
# CHECK: env -u | ||
# CHECK: # executed command: env -u | ||
# CHECK-NOT: # error: | ||
# CHECK: -- | ||
|
||
# CHECK: PASS: shtest-env :: env-args-nested-none.txt ({{[^)]*}}) | ||
# CHECK: env env env | ||
# CHECK: # executed command: env env env | ||
# CHECK-NOT: # error: | ||
# CHECK: -- | ||
|
||
# CHECK: PASS: shtest-env :: env-calls-env.txt ({{[^)]*}}) | ||
# CHECK: env env | {{.*}} | ||
# CHECK: # executed command: env env | ||
# CHECK-NOT: # error: | ||
# CHECK: -- | ||
|
||
# CHECK: PASS: shtest-env :: env-no-subcommand.txt ({{[^)]*}}) | ||
# CHECK: env | {{.*}} | ||
# CHECK: # executed command: env | ||
# CHECK: env FOO=2 BAR=1 | {{.*}} | ||
# CHECK: # executed command: env FOO=2 BAR=1 | ||
# CHECK-NOT: # error: | ||
# CHECK: -- | ||
|
||
# CHECK: PASS: shtest-env :: env-u.txt ({{[^)]*}}) | ||
# CHECK: env -u FOO | {{.*}} | ||
# CHECK: # executed command: env -u FOO | ||
# CHECK-NOT: # error: | ||
jh7370 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# CHECK: -- | ||
|
||
# CHECK: PASS: shtest-env :: env.txt ({{[^)]*}}) | ||
# CHECK: env A_FOO=999 | {{.*}} | ||
# CHECK: # executed command: env A_FOO=999 | ||
# CHECK-NOT: # error: | ||
# CHECK: -- | ||
|
||
# CHECK: PASS: shtest-env :: mixed.txt ({{[^)]*}}) | ||
# CHECK: env A_FOO=999 -u FOO | {{.*}} | ||
# CHECK: # executed command: env A_FOO=999 -u FOO | ||
# CHECK-NOT: # error: | ||
# CHECK: -- | ||
|
||
# CHECK: Total Discovered Tests: 9 | ||
# CHECK: Passed: 9 {{\([0-9]*\.[0-9]*%\)}} | ||
# CHECK-NOT: {{.}} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.