2017-08-19 01:32:57 +08:00
|
|
|
# Check the env command
|
|
|
|
#
|
2019-08-22 11:42:01 +08:00
|
|
|
# RUN: not %{lit} -j 1 -a -v %{inputs}/shtest-env \
|
2019-08-03 14:08:19 +08:00
|
|
|
# RUN: | FileCheck -match-full-lines %s
|
|
|
|
#
|
|
|
|
# END.
|
|
|
|
|
|
|
|
# Make sure env commands are included in printed commands.
|
|
|
|
|
[lit] Fix `not` calling internal commands
Without this patch, when using lit's internal shell, if `not` on a lit
RUN line calls `env`, `diff`, or any of the other in-process shell
builtins that lit implements, lit accidentally searches for the latter
as an external executable. What's worse is that works fine when a
developer is testing on a platform where those executables are
available and behave as expected, but it then breaks on other
platforms.
`not` seems useful for some builtins, such as `diff`, so this patch
supports such uses. `not --crash` does not seem useful for builtins,
so this patch diagnoses such uses. In all cases, this patch ensures
shell builtins are found behind any sequence of `env` and `not`
commands.
`not` calling `env` calling an external command appears useful when
the `env` and external command are part of a lit substitution, as in
D65156. This patch supports that by looking through any sequence of
`env` and `not` commands, building the environment from the `env`s,
and storing the `not`s. The `not`s are then added back to the command
line without the `env`s to execute externally. This avoids the need
to replicate the `not` implementation, in particular the `--crash`
option, in lit.
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D66531
2019-11-05 23:05:10 +08:00
|
|
|
# CHECK: -- Testing: 16 tests{{.*}}
|
2019-08-22 11:42:01 +08:00
|
|
|
|
|
|
|
# CHECK: FAIL: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
|
2019-11-01 22:14:22 +08:00
|
|
|
# CHECK: $ "env" "FOO=1"
|
2019-08-22 11:42:01 +08:00
|
|
|
# CHECK: Error: 'env' requires a subcommand
|
|
|
|
# CHECK: error: command failed with exit status: {{.*}}
|
|
|
|
|
|
|
|
# CHECK: FAIL: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
|
2019-11-01 22:14:22 +08:00
|
|
|
# CHECK: $ "env" "-u" "FOO"
|
2019-08-22 11:42:01 +08:00
|
|
|
# CHECK: Error: 'env' requires a subcommand
|
|
|
|
# CHECK: error: command failed with exit status: {{.*}}
|
|
|
|
|
|
|
|
# CHECK: FAIL: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})
|
2019-11-01 22:14:22 +08:00
|
|
|
# CHECK: $ "env" "-u"
|
|
|
|
# CHECK: Error: 'env' requires a subcommand
|
|
|
|
# CHECK: error: command failed with exit status: {{.*}}
|
|
|
|
|
|
|
|
# CHECK: FAIL: shtest-env :: env-args-nested-none.txt ({{[^)]*}})
|
|
|
|
# CHECK: $ "env" "env" "env"
|
2019-08-22 11:42:01 +08:00
|
|
|
# CHECK: Error: 'env' requires a subcommand
|
|
|
|
# CHECK: error: command failed with exit status: {{.*}}
|
|
|
|
|
|
|
|
# CHECK: FAIL: shtest-env :: env-args-none.txt ({{[^)]*}})
|
2019-11-01 22:14:22 +08:00
|
|
|
# CHECK: $ "env"
|
2019-08-22 11:42:01 +08:00
|
|
|
# CHECK: Error: 'env' requires a subcommand
|
|
|
|
# CHECK: error: command failed with exit status: {{.*}}
|
|
|
|
|
2019-10-31 02:22:16 +08:00
|
|
|
# CHECK: FAIL: shtest-env :: env-calls-cd.txt ({{[^)]*}})
|
|
|
|
# CHECK: $ "env" "-u" "FOO" "BAR=3" "cd" "foobar"
|
|
|
|
# CHECK: Error: 'env' cannot call 'cd'
|
|
|
|
# CHECK: error: command failed with exit status: {{.*}}
|
|
|
|
|
|
|
|
# CHECK: FAIL: shtest-env :: env-calls-colon.txt ({{[^)]*}})
|
|
|
|
# CHECK: $ "env" "-u" "FOO" "BAR=3" ":"
|
|
|
|
# CHECK: Error: 'env' cannot call ':'
|
|
|
|
# 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: Error: 'env' cannot call 'echo'
|
|
|
|
# CHECK: error: command failed with exit status: {{.*}}
|
|
|
|
|
2019-11-01 22:14:22 +08:00
|
|
|
# CHECK: PASS: shtest-env :: env-calls-env.txt ({{[^)]*}})
|
|
|
|
# CHECK: $ "env" "env" "{{[^"]*}}" "print_environment.py"
|
|
|
|
# CHECK: $ "env" "FOO=2" "env" "BAR=1" "{{[^"]*}}" "print_environment.py"
|
|
|
|
# CHECK: $ "env" "-u" "FOO" "env" "-u" "BAR" "{{[^"]*}}" "print_environment.py"
|
|
|
|
# CHECK: $ "env" "-u" "FOO" "BAR=1" "env" "-u" "BAR" "FOO=2" "{{[^"]*}}" "print_environment.py"
|
|
|
|
# CHECK: $ "env" "-u" "FOO" "BAR=1" "env" "-u" "BAR" "FOO=2" "env" "BAZ=3" "{{[^"]*}}" "print_environment.py"
|
|
|
|
# CHECK-NOT: ${{.*}}print_environment.py
|
|
|
|
|
2019-10-31 02:22:16 +08:00
|
|
|
# CHECK: FAIL: shtest-env :: env-calls-export.txt ({{[^)]*}})
|
|
|
|
# CHECK: $ "env" "-u" "FOO" "BAR=3" "export" "BAZ=3"
|
|
|
|
# CHECK: Error: 'env' cannot call 'export'
|
|
|
|
# CHECK: error: command failed with exit status: {{.*}}
|
|
|
|
|
|
|
|
# CHECK: FAIL: shtest-env :: env-calls-mkdir.txt ({{[^)]*}})
|
|
|
|
# CHECK: $ "env" "-u" "FOO" "BAR=3" "mkdir" "foobar"
|
|
|
|
# CHECK: Error: 'env' cannot call 'mkdir'
|
|
|
|
# CHECK: error: command failed with exit status: {{.*}}
|
|
|
|
|
[lit] Fix `not` calling internal commands
Without this patch, when using lit's internal shell, if `not` on a lit
RUN line calls `env`, `diff`, or any of the other in-process shell
builtins that lit implements, lit accidentally searches for the latter
as an external executable. What's worse is that works fine when a
developer is testing on a platform where those executables are
available and behave as expected, but it then breaks on other
platforms.
`not` seems useful for some builtins, such as `diff`, so this patch
supports such uses. `not --crash` does not seem useful for builtins,
so this patch diagnoses such uses. In all cases, this patch ensures
shell builtins are found behind any sequence of `env` and `not`
commands.
`not` calling `env` calling an external command appears useful when
the `env` and external command are part of a lit substitution, as in
D65156. This patch supports that by looking through any sequence of
`env` and `not` commands, building the environment from the `env`s,
and storing the `not`s. The `not`s are then added back to the command
line without the `env`s to execute externally. This avoids the need
to replicate the `not` implementation, in particular the `--crash`
option, in lit.
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D66531
2019-11-05 23:05:10 +08:00
|
|
|
# CHECK: FAIL: shtest-env :: env-calls-not-builtin.txt ({{[^)]*}})
|
|
|
|
# CHECK: $ "env" "-u" "FOO" "BAR=3" "not" "rm" "{{.*}}.no-such-file"
|
|
|
|
# CHECK: Error: 'env' cannot call 'rm'
|
|
|
|
# CHECK: error: command failed with exit status: {{.*}}
|
|
|
|
|
2019-10-31 02:22:16 +08:00
|
|
|
# CHECK: FAIL: shtest-env :: env-calls-rm.txt ({{[^)]*}})
|
|
|
|
# CHECK: $ "env" "-u" "FOO" "BAR=3" "rm" "foobar"
|
|
|
|
# CHECK: Error: 'env' cannot call 'rm'
|
|
|
|
# CHECK: error: command failed with exit status: {{.*}}
|
|
|
|
|
2019-08-03 14:08:19 +08:00
|
|
|
# CHECK: PASS: shtest-env :: env-u.txt ({{[^)]*}})
|
|
|
|
# CHECK: $ "{{[^"]*}}" "print_environment.py"
|
|
|
|
# CHECK: $ "env" "-u" "FOO" "{{[^"]*}}" "print_environment.py"
|
|
|
|
# CHECK: $ "env" "-u" "FOO" "-u" "BAR" "{{[^"]*}}" "print_environment.py"
|
2019-10-31 02:22:16 +08:00
|
|
|
# CHECK-NOT: ${{.*}}print_environment.py
|
2019-08-03 14:08:19 +08:00
|
|
|
|
|
|
|
# CHECK: PASS: shtest-env :: env.txt ({{[^)]*}})
|
|
|
|
# CHECK: $ "env" "A_FOO=999" "{{[^"]*}}" "print_environment.py"
|
|
|
|
# CHECK: $ "env" "A_FOO=1" "B_BAR=2" "C_OOF=3" "{{[^"]*}}" "print_environment.py"
|
2019-10-31 02:22:16 +08:00
|
|
|
# CHECK-NOT: ${{.*}}print_environment.py
|
2019-08-03 14:08:19 +08:00
|
|
|
|
|
|
|
# CHECK: PASS: shtest-env :: mixed.txt ({{[^)]*}})
|
|
|
|
# CHECK: $ "env" "A_FOO=999" "-u" "FOO" "{{[^"]*}}" "print_environment.py"
|
|
|
|
# CHECK: $ "env" "A_FOO=1" "-u" "FOO" "B_BAR=2" "-u" "BAR" "C_OOF=3" "{{[^"]*}}" "print_environment.py"
|
2019-10-31 02:22:16 +08:00
|
|
|
# CHECK-NOT: ${{.*}}print_environment.py
|
2019-08-03 14:08:19 +08:00
|
|
|
|
2019-11-01 22:14:22 +08:00
|
|
|
# CHECK: Expected Passes : 4
|
[lit] Fix `not` calling internal commands
Without this patch, when using lit's internal shell, if `not` on a lit
RUN line calls `env`, `diff`, or any of the other in-process shell
builtins that lit implements, lit accidentally searches for the latter
as an external executable. What's worse is that works fine when a
developer is testing on a platform where those executables are
available and behave as expected, but it then breaks on other
platforms.
`not` seems useful for some builtins, such as `diff`, so this patch
supports such uses. `not --crash` does not seem useful for builtins,
so this patch diagnoses such uses. In all cases, this patch ensures
shell builtins are found behind any sequence of `env` and `not`
commands.
`not` calling `env` calling an external command appears useful when
the `env` and external command are part of a lit substitution, as in
D65156. This patch supports that by looking through any sequence of
`env` and `not` commands, building the environment from the `env`s,
and storing the `not`s. The `not`s are then added back to the command
line without the `env`s to execute externally. This avoids the need
to replicate the `not` implementation, in particular the `--crash`
option, in lit.
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D66531
2019-11-05 23:05:10 +08:00
|
|
|
# CHECK: Unexpected Failures: 12
|
2019-08-22 11:42:01 +08:00
|
|
|
# CHECK-NOT: {{.}}
|