llvm-project/llvm/utils/lit/tests/shtest-env-negative.py
Harini0924 178392454e
[llvm-lit] Print environment variables when using env without subcommand (#98414)
This patch addresses an issue with lit's internal shell when env is
without any arguments, it fails with exit code 127 because `env`
requires a subcommand. This patch addresses the issue by encoding the
command to properly return environment variables even when no arguments
are provided.

The error occurred when running the command 
` LIT_USE_INTERNAL_SHELL=1 ninja check-llvm`.

fixes: #102383
This is part of the test cleanups proposed in the RFC: [[RFC] Enabling
the Lit Internal Shell by
Default](https://discourse.llvm.org/t/rfc-enabling-the-lit-internal-shell-by-default/80179)
2024-08-29 10:00:58 -07:00

50 lines
1.8 KiB
Python

## 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: {{.}}