1# Check the env command
2#
3# RUN: not %{lit} -j 1 -a -v %{inputs}/shtest-env \
4# RUN: | FileCheck -match-full-lines %s
5#
6# END.
7
8# Make sure env commands are included in printed commands.
9
10# CHECK: -- Testing: 16 tests{{.*}}
11
12# CHECK: FAIL: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
13# CHECK: $ "env" "FOO=1"
14# CHECK: Error: 'env' requires a subcommand
15# CHECK: error: command failed with exit status: {{.*}}
16
17# CHECK: FAIL: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
18# CHECK: $ "env" "-u" "FOO"
19# CHECK: Error: 'env' requires a subcommand
20# CHECK: error: command failed with exit status: {{.*}}
21
22# CHECK: FAIL: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})
23# CHECK: $ "env" "-u"
24# CHECK: Error: 'env' requires a subcommand
25# CHECK: error: command failed with exit status: {{.*}}
26
27# CHECK: FAIL: shtest-env :: env-args-nested-none.txt ({{[^)]*}})
28# CHECK: $ "env" "env" "env"
29# CHECK: Error: 'env' requires a subcommand
30# CHECK: error: command failed with exit status: {{.*}}
31
32# CHECK: FAIL: shtest-env :: env-args-none.txt ({{[^)]*}})
33# CHECK: $ "env"
34# CHECK: Error: 'env' requires a subcommand
35# CHECK: error: command failed with exit status: {{.*}}
36
37# CHECK: FAIL: shtest-env :: env-calls-cd.txt ({{[^)]*}})
38# CHECK: $ "env" "-u" "FOO" "BAR=3" "cd" "foobar"
39# CHECK: Error: 'env' cannot call 'cd'
40# CHECK: error: command failed with exit status: {{.*}}
41
42# CHECK: FAIL: shtest-env :: env-calls-colon.txt ({{[^)]*}})
43# CHECK: $ "env" "-u" "FOO" "BAR=3" ":"
44# CHECK: Error: 'env' cannot call ':'
45# CHECK: error: command failed with exit status: {{.*}}
46
47# CHECK: FAIL: shtest-env :: env-calls-echo.txt ({{[^)]*}})
48# CHECK: $ "env" "-u" "FOO" "BAR=3" "echo" "hello" "world"
49# CHECK: Error: 'env' cannot call 'echo'
50# CHECK: error: command failed with exit status: {{.*}}
51
52# CHECK: PASS: shtest-env :: env-calls-env.txt ({{[^)]*}})
53# CHECK: $ "env" "env" "{{[^"]*}}" "print_environment.py"
54# CHECK: $ "env" "FOO=2" "env" "BAR=1" "{{[^"]*}}" "print_environment.py"
55# CHECK: $ "env" "-u" "FOO" "env" "-u" "BAR" "{{[^"]*}}" "print_environment.py"
56# CHECK: $ "env" "-u" "FOO" "BAR=1" "env" "-u" "BAR" "FOO=2" "{{[^"]*}}" "print_environment.py"
57# CHECK: $ "env" "-u" "FOO" "BAR=1" "env" "-u" "BAR" "FOO=2" "env" "BAZ=3" "{{[^"]*}}" "print_environment.py"
58# CHECK-NOT: ${{.*}}print_environment.py
59
60# CHECK: FAIL: shtest-env :: env-calls-export.txt ({{[^)]*}})
61# CHECK: $ "env" "-u" "FOO" "BAR=3" "export" "BAZ=3"
62# CHECK: Error: 'env' cannot call 'export'
63# CHECK: error: command failed with exit status: {{.*}}
64
65# CHECK: FAIL: shtest-env :: env-calls-mkdir.txt ({{[^)]*}})
66# CHECK: $ "env" "-u" "FOO" "BAR=3" "mkdir" "foobar"
67# CHECK: Error: 'env' cannot call 'mkdir'
68# CHECK: error: command failed with exit status: {{.*}}
69
70# CHECK: FAIL: shtest-env :: env-calls-not-builtin.txt ({{[^)]*}})
71# CHECK: $ "env" "-u" "FOO" "BAR=3" "not" "rm" "{{.*}}.no-such-file"
72# CHECK: Error: 'env' cannot call 'rm'
73# CHECK: error: command failed with exit status: {{.*}}
74
75# CHECK: FAIL: shtest-env :: env-calls-rm.txt ({{[^)]*}})
76# CHECK: $ "env" "-u" "FOO" "BAR=3" "rm" "foobar"
77# CHECK: Error: 'env' cannot call 'rm'
78# CHECK: error: command failed with exit status: {{.*}}
79
80# CHECK: PASS: shtest-env :: env-u.txt ({{[^)]*}})
81# CHECK: $ "{{[^"]*}}" "print_environment.py"
82# CHECK: $ "env" "-u" "FOO" "{{[^"]*}}" "print_environment.py"
83# CHECK: $ "env" "-u" "FOO" "-u" "BAR" "{{[^"]*}}" "print_environment.py"
84# CHECK-NOT: ${{.*}}print_environment.py
85
86# CHECK: PASS: shtest-env :: env.txt ({{[^)]*}})
87# CHECK: $ "env" "A_FOO=999" "{{[^"]*}}" "print_environment.py"
88# CHECK: $ "env" "A_FOO=1" "B_BAR=2" "C_OOF=3" "{{[^"]*}}" "print_environment.py"
89# CHECK-NOT: ${{.*}}print_environment.py
90
91# CHECK: PASS: shtest-env :: mixed.txt ({{[^)]*}})
92# CHECK: $ "env" "A_FOO=999" "-u" "FOO" "{{[^"]*}}" "print_environment.py"
93# CHECK: $ "env" "A_FOO=1" "-u" "FOO" "B_BAR=2" "-u" "BAR" "C_OOF=3" "{{[^"]*}}" "print_environment.py"
94# CHECK-NOT: ${{.*}}print_environment.py
95
96# CHECK: Passed:  4
97# CHECK: Failed: 12
98# CHECK-NOT: {{.}}
99