Skip to content

Commit 46a3b4d

Browse files
[clang] Rewrite tests relying on shell environment variable features
This patch rewrites a couple tsts that fail when running with lit's internal shell enabled due to assumptions about setting environment variables. There were a couple cases where there was an implict env. Most of the cases needed unset swapped for env -u. Toeards #102699. Reviewers: petrhosek, efriedma-quic, Sirraide, carlocab, rnk, ilovepi Reviewed By: carlocab, rnk, ilovepi Pull Request: #156904
1 parent b208bda commit 46a3b4d

File tree

7 files changed

+56
-53
lines changed

7 files changed

+56
-53
lines changed

clang/test/Driver/config-file3.c

Lines changed: 36 additions & 34 deletions
Large diffs are not rendered by default.

clang/test/Driver/config-zos.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
// REQUIRES: shell
1+
// Needs symlinks
2+
// UNSUPPORTED: system-windows
23
// REQUIRES: systemz-registered-target
34

4-
// RUN: unset CLANG_NO_DEFAULT_CONFIG
55
// RUN: rm -rf %t && mkdir %t
66

77
// RUN: mkdir -p %t/testbin
88
// RUN: mkdir -p %t/etc
99
// RUN: ln -s %clang %t/testbin/clang
1010
// RUN: echo "-DXYZ=789" >%t/etc/clang.cfg
11-
// RUN: %t/testbin/clang --target=s390x-ibm-zos -c -### -no-canonical-prefixes %s 2>&1 | FileCheck -DDIR=%t %s
12-
// RUN: %t/testbin/clang --target=s390x-ibm-zos -c -### -no-canonical-prefixes --no-default-config %s 2>&1 | FileCheck -check-prefix=NOCONFIG %s
11+
// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testbin/clang --target=s390x-ibm-zos -c -### -no-canonical-prefixes %s 2>&1 | FileCheck -DDIR=%t %s
12+
// RUN: env -u CLANG_NO_DEFAULT_CONFIG %t/testbin/clang --target=s390x-ibm-zos -c -### -no-canonical-prefixes --no-default-config %s 2>&1 | FileCheck -check-prefix=NOCONFIG %s
1313
//
1414
// CHECK: Configuration file: [[DIR]]/etc/clang.cfg
1515
// CHECK: "-D" "XYZ=789"

clang/test/Driver/config-zos1.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
// REQUIRES: shell
1+
// UNSUPPORTED: system-windows
22
// REQUIRES: systemz-registered-target
33

4-
// RUN: unset CLANG_NO_DEFAULT_CONFIG
5-
64
// RUN: export CLANG_CONFIG_PATH=%S/Inputs/config-zos
7-
// RUN: %clang --target=s390x-ibm-zos -c -### %s 2>&1 | FileCheck %s
5+
// RUN: env -u CLANG_NO_DEFAULT_CONFIG %clang --target=s390x-ibm-zos -c -### %s 2>&1 | FileCheck %s
86
// CHECK: Configuration file: {{.*}}/Inputs/config-zos/clang.cfg
97
// CHECK: "-D" "ABC=123"
108

119
// RUN: export CLANG_CONFIG_PATH=%S/Inputs/config-zos/def.cfg
12-
// RUN: %clang --target=s390x-ibm-zos -c -### %s 2>&1 | FileCheck %s -check-prefix=CHECK-DEF
10+
// RUN: env -u CLANG_NO_DEFAULT_CONFIG %clang --target=s390x-ibm-zos -c -### %s 2>&1 | FileCheck %s -check-prefix=CHECK-DEF
1311
// CHECK-DEF: Configuration file: {{.*}}/Inputs/config-zos/def.cfg
1412
// CHECK-DEF: "-D" "DEF=456"
1513

1614
// RUN: export CLANG_CONFIG_PATH=%S/Inputs/config-zos/Garbage
17-
// RUN: not %clang --target=s390x-ibm-zos -c -### %s 2>&1 | FileCheck %s -check-prefix=CHECK-ERR
15+
// RUN: env -u CLANG_NO_DEFAULT_CONFIG not %clang --target=s390x-ibm-zos -c -### %s 2>&1 | FileCheck %s -check-prefix=CHECK-ERR
1816
// CHECK-ERR: error: configuration file '{{.*}}/Inputs/config-zos/Garbage' cannot be found
1917

2018
// The directory exists but no clang.cfg in it
2119
// RUN: export CLANG_CONFIG_PATH=%S/Inputs/config-zos/tst
22-
// RUN: not %clang --target=s390x-ibm-zos -c -### %s 2>&1 | FileCheck %s -check-prefix=CHECK-ERRDIR
20+
// RUN: env -u CLANG_NO_DEFAULT_CONFIG not %clang --target=s390x-ibm-zos -c -### %s 2>&1 | FileCheck %s -check-prefix=CHECK-ERRDIR
2321
// CHECK-ERRDIR: error: configuration file '{{.*}}/Inputs/config-zos/tst/clang.cfg' cannot be found

clang/test/Driver/coverage.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// GCNO-LOCATION-REL: "-coverage-notes-file={{.*}}{{/|\\\\}}foo/bar.gcno"
1919

2020
/// GCC allows PWD to change the paths.
21-
// RUN: %if system-linux %{ PWD=/proc/self/cwd %clang -### -c --coverage %s -o foo/bar.o 2>&1 | FileCheck --check-prefix=PWD %s %}
21+
// RUN: %if system-linux %{ env PWD=/proc/self/cwd %clang -### -c --coverage %s -o foo/bar.o 2>&1 | FileCheck --check-prefix=PWD %s %}
2222
// PWD: "-coverage-notes-file=/proc/self/cwd/foo/bar.gcno" "-coverage-data-file=/proc/self/cwd/foo/bar.gcda"
2323

2424
/// Don't warn -Wunused-command-line-argument.
@@ -50,6 +50,6 @@
5050
// LINK2: -cc1{{.*}} "-coverage-notes-file={{.*}}{{/|\\\\}}f/gb.gcno" "-coverage-data-file={{.*}}{{/|\\\\}}f/gb.gcda"
5151

5252
/// GCC allows PWD to change the paths.
53-
// RUN: %if system-linux %{ PWD=/proc/self/cwd %clang -### --coverage d/a.c d/b.c -o e/x -fprofile-dir=f 2>&1 | FileCheck %s --check-prefix=LINK3 %}
53+
// RUN: %if system-linux %{ env PWD=/proc/self/cwd %clang -### --coverage d/a.c d/b.c -o e/x -fprofile-dir=f 2>&1 | FileCheck %s --check-prefix=LINK3 %}
5454
// LINK3: -cc1{{.*}} "-coverage-notes-file=/proc/self/cwd/e/x-a.gcno" "-coverage-data-file=f/proc/self/cwd/e/x-a.gcda"
5555
// LINK3: -cc1{{.*}} "-coverage-notes-file=/proc/self/cwd/e/x-b.gcno" "-coverage-data-file=f/proc/self/cwd/e/x-b.gcda"

clang/test/Modules/crash-vfs-path-symlink-component.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// REQUIRES: crash-recovery, shell
1+
// Needs symlinks
2+
// UNSUPPORTED: system-windows
3+
// REQUIRES: crash-recovery
24

35
// FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it?
46
// XFAIL: target={{.*-windows-gnu}}
@@ -59,7 +61,7 @@
5961
// %/t/i directory containing the symlink component.
6062

6163
// RUN: rm -rf %/t/i
62-
// RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH
64+
// RUN: env -u FORCE_CLANG_DIAGNOSTICS_CRASH \
6365
// RUN: %clang -E %s -I %/t/i -isysroot %/t/sysroot/ \
6466
// RUN: -ivfsoverlay %t/crash-vfs-*.cache/vfs/vfs.yaml -fmodules \
6567
// RUN: -fmodules-cache-path=%t/m/ 2>&1 \

clang/test/Modules/crash-vfs-path-traversal.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// REQUIRES: crash-recovery, shell
1+
// REQUIRES: crash-recovery
22
// UNSUPPORTED: ms-sdk, target={{.*-(ps4|ps5)}}
33

44
// FIXME: Canonicalizing paths to remove relative traversal components
@@ -57,7 +57,7 @@
5757
// RUN: sed -e "s@usr/include@usr/include/../include@g" \
5858
// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml > %t/vfs.yaml
5959
// RUN: cp %t/vfs.yaml %t/crash-vfs-*.cache/vfs/vfs.yaml
60-
// RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH
60+
// RUN: env -u FORCE_CLANG_DIAGNOSTICS_CRASH \
6161
// RUN: %clang -E %s -I %S/Inputs/crash-recovery -isysroot %/t/i/ \
6262
// RUN: -ivfsoverlay %t/crash-vfs-*.cache/vfs/vfs.yaml -fmodules \
6363
// RUN: -fmodules-cache-path=%t/m/ 2>&1 \

clang/test/Modules/crash-vfs-relative-overlay.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// REQUIRES: crash-recovery, shell
1+
// UNSUPPORTED: system-windows
2+
// REQUIRES: crash-recovery
23

34
// FIXME: This XFAIL is cargo-culted from crash-report.c. Do we need it?
45
// XFAIL: target={{.*-windows-gnu}}
@@ -52,7 +53,7 @@
5253
// Test that reading the YAML file will yield the correct path after
5354
// the overlay dir is prefixed to access headers in .cache/vfs directory.
5455

55-
// RUN: unset FORCE_CLANG_DIAGNOSTICS_CRASH
56+
// RUN: env -u FORCE_CLANG_DIAGNOSTICS_CRASH \
5657
// RUN: %clang -E %s -I %S/Inputs/crash-recovery/usr/include -isysroot %/t/i/ \
5758
// RUN: -ivfsoverlay %t/crash-vfs-*.cache/vfs/vfs.yaml -fmodules \
5859
// RUN: -fmodules-cache-path=%t/m/ 2>&1 \

0 commit comments

Comments
 (0)