Skip to content

Commit ad05b82

Browse files
committed
Fix the following CAS related tests for Windows (#11355)
Clang :: ClangScanDeps/cas-fs-prefix-mapping.c Clang :: ClangScanDeps/include-tree-prefix-mapping-pch-remap.c Clang :: ClangScanDeps/include-tree-prefix-mapping.c Clang :: ClangScanDeps/modules-cas-fs-prefix-mapping-caching.c Clang :: ClangScanDeps/modules-cas-fs-prefix-mapping.c Clang :: ClangScanDeps/modules-include-tree-prefix-map.c Clang :: ClangScanDeps/modules-pch-cas-fs-prefix-mapping-caching.c Clang :: ClangScanDeps/modules-pch-cas-fs-prefix-mapping.c (Cherry picked from commit 8de16d1)
1 parent 06cca97 commit ad05b82

17 files changed

+492
-312
lines changed

clang/test/ClangScanDeps/cas-fs-prefix-mapping.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,40 @@
44
// REQUIRES: ondisk_cas
55
// RUN: rm -rf %t
66
// RUN: split-file %s %t
7-
// RUN: sed -e "s|DIR|%t|g" -e "s|CLANG|%clang|g" -e "s|SDK|%S/Inputs/SDK|g" %t/cdb.json.template > %t/cdb.json
7+
// RUN: sed -e "s|DIR|%/t|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb.json.template > %t/cdb.json
88

99
// == Tree
1010
// Ensure the filesystem has the mapped paths.
1111

1212
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-tree -cas-path %t/cas \
13-
// RUN: -prefix-map=%t=/^src -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc \
13+
// RUN: -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \
1414
// RUN: | sed -E 's/tree ([^ ]+) for.*/\1/' > %t/tree_id.txt
1515
// RUN: llvm-cas -cas %t/cas -ls-tree-recursive @%t/tree_id.txt > %t/tree_result.txt
16-
// RUN: FileCheck %s -input-file %t/tree_result.txt -check-prefix=FILES
16+
// RUN: FileCheck %s -input-file %t/tree_result.txt -DROOT=%{/roott} -check-prefix=FILES
1717

18-
// FILES: file llvmcas://{{.*}} /^sdk/usr/include/stdlib.h
19-
// FILES: file llvmcas://{{.*}} /^src/t.c
20-
// FILES: file llvmcas://{{.*}} /^src/top.h
21-
// FILES: file llvmcas://{{.*}} /^tc/lib/clang/{{.*}}/include/stdarg.h
18+
// FILES: file llvmcas://{{.*}} [[ROOT]]^sdk/usr/include/stdlib.h
19+
// FILES: file llvmcas://{{.*}} [[ROOT]]^src/t.c
20+
// FILES: file llvmcas://{{.*}} [[ROOT]]^src/top.h
21+
// FILES: file llvmcas://{{.*}} [[ROOT]]^tc/lib/clang/{{.*}}/include/stdarg.h
2222

2323
// == Full Tree
2424
// This should have the same filesystem as above, and we also check the command-
2525
// line.
2626

2727
// RUN: cat %t/tree_id.txt > %t/full_tree_result.txt
2828
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-tree-full -cas-path %t/cas \
29-
// RUN: -prefix-map=%t=/^src -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc \
29+
// RUN: -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \
3030
// RUN: >> %t/full_tree_result.txt
31-
// RUN: FileCheck %s -input-file %t/full_tree_result.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK
31+
// RUN: cat %t/full_tree_result.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t --sanitize SDK_PREFIX=%/S/Inputs/SDK --sanitize ROOT^=%/root^ --enable-yaml-compatibility %s
3232

3333
// == Full
3434
// Same as full tree.
3535

3636
// RUN: cat %t/tree_id.txt > %t/full_result.txt
3737
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -cas-path %t/cas \
38-
// RUN: -prefix-map=%t=/^src -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc \
38+
// RUN: -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \
3939
// RUN: >> %t/full_result.txt
40-
// RUN: FileCheck %s -input-file %t/full_result.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK
40+
// RUN: cat %t/full_result.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t --sanitize SDK_PREFIX=%/S/Inputs/SDK --sanitize ROOT^=%/root^ --enable-yaml-compatibility %s
4141

4242
// CHECK: [[MAPPED_FS_ID:llvmcas://[[:xdigit:]]+]]
4343
// CHECK: "modules": []
@@ -49,36 +49,36 @@
4949
// CHECK: "clang-module-deps": []
5050
// CHECK: "command-line": [
5151
// CHECK: "-fcas-path"
52-
// CHECK-NEXT: "[[PREFIX]]/cas"
52+
// CHECK-NEXT: "PREFIX{{/|\\\\}}cas"
5353
// CHECK: "-fcas-fs"
5454
// CHECK-NEXT: "[[MAPPED_FS_ID]]"
5555
// CHECK: "-fcas-fs-working-directory"
56-
// CHECK-NEXT: "/^src"
56+
// CHECK-NEXT: "ROOT^src"
5757
// CHECK: "-x"
5858
// CHECK-NEXT: "c"
59-
// CHECK-NEXT: "/^src/t.c"
59+
// CHECK-NEXT: "ROOT^src{{/|\\\\}}t.c"
6060
// CHECK: "-isysroot"
61-
// CHECK-NEXT: "/^sdk"
61+
// CHECK-NEXT: "ROOT^sdk"
6262
// CHECK: "-resource-dir"
63-
// CHECK-NEXT: "/^tc/lib/clang/{{.*}}"
63+
// CHECK-NEXT: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}"
6464
// CHECK: "-isystem"
65-
// CHECK-NEXT: "/^sdk/usr/local/include
65+
// CHECK-NEXT: "ROOT^sdk{{/|\\\\}}usr{{/|\\\\}}local{{/|\\\\}}include
6666
// CHECK: "-isystem"
67-
// CHECK-NEXT: "/^tc/lib/clang/{{.*}}/include"
67+
// CHECK-NEXT: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}{{/|\\\\}}include"
6868
// CHECK: "-internal-externc-isystem"
69-
// CHECK-NEXT: "/^sdk/usr/include"
70-
// CHECK: "-fdebug-compilation-dir=/^src"
71-
// CHECK: "-fcoverage-compilation-dir=/^src"
72-
// CHECK-NOT: [[PREFIX]]
73-
// CHECK-NOT: [[SDK_PREFIX]]
69+
// CHECK-NEXT: "ROOT^sdk{{/|\\\\}}usr{{/|\\\\}}include"
70+
// CHECK: "-fdebug-compilation-dir=ROOT^src"
71+
// CHECK: "-fcoverage-compilation-dir=ROOT^src"
72+
// CHECK-NOT: PREFIX
73+
// CHECK-NOT: SDK_PREFIX
7474
// CHECK: ]
7575
// CHECK: "file-deps": [
76-
// CHECK: "[[PREFIX]]/t.c"
77-
// CHECK: "[[PREFIX]]/top.h"
78-
// CHECK: "{{.*}}include/stdarg.h"
79-
// CHECK: "[[SDK_PREFIX]]/usr/include/stdlib.h"
76+
// CHECK: "PREFIX{{/|\\\\}}t.c"
77+
// CHECK: "PREFIX{{/|\\\\}}top.h"
78+
// CHECK: "{{.*}}include{{/|\\\\}}stdarg.h"
79+
// CHECK: "SDK_PREFIX{{/|\\\\}}usr{{/|\\\\}}include{{/|\\\\}}stdlib.h"
8080
// CHECK: ]
81-
// CHECK: "input-file": "[[PREFIX]]/t.c"
81+
// CHECK: "input-file": "PREFIX{{/|\\\\}}t.c"
8282

8383
//--- cdb.json.template
8484
[

clang/test/ClangScanDeps/include-tree-prefix-mapping-pch-remap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// REQUIRES: ondisk_cas
22
// RUN: rm -rf %t
33
// RUN: split-file %s %t
4-
// RUN: sed -e "s|DIR|%t|g" %t/cdb.json.template > %t/cdb.json
4+
// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
55

66
// RUN: clang-scan-deps -compilation-database %t/cdb.json \
77
// RUN: -format experimental-include-tree-full -cas-path %t/cas \
8-
// RUN: -prefix-map=%t=/^src -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc > %t/deps.json
8+
// RUN: -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc > %t/deps.json
99

1010
//--- cdb.json.template
1111
[{

clang/test/ClangScanDeps/include-tree-prefix-mapping.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
// REQUIRES: ondisk_cas
22
// RUN: rm -rf %t
33
// RUN: split-file %s %t
4-
// RUN: sed -e "s|DIR|%t|g" -e "s|CLANG|%clang|g" -e "s|SDK|%S/Inputs/SDK|g" %t/cdb.json.template > %t/cdb.json
4+
// RUN: sed -e "s|DIR|%/t|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb.json.template > %t/cdb.json
55

66
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-include-tree -cas-path %t/cas \
7-
// RUN: -prefix-map=%t=/^src -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc > %t/result.txt
8-
// RUN: FileCheck %s -input-file %t/result.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK
7+
// RUN: -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc > %t/result.txt
8+
// RUN: cat %t/result.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t --sanitize SDK_PREFIX=%/S/Inputs/SDK --sanitize ROOT^=%/root^ %s
99

10-
// CHECK: {{.*}} - [[PREFIX]]/t.c
11-
// CHECK-NOT: [[PREFIX]]
12-
// CHECK-NOT: [[SDK_PREFIX]]
13-
// CHECK: /^src{{[/\\]}}t.c
14-
// CHECK: /^src{{[/\\]}}top.h
15-
// CHECK: /^tc{{[/\\]}}lib{{[/\\]}}clang{{[/\\]}}{{.*}}{{[/\\]}}include{{[/\\]}}stdarg.h
16-
// CHECK: /^sdk{{[/\\]}}usr{{[/\\]}}include{{[/\\]}}stdlib.h
10+
// CHECK: {{.*}} - PREFIX{{/|\\}}t.c
11+
// CHECK-NOT: PREFIX
12+
// CHECK-NOT: SDK_PREFIX
13+
// CHECK: ROOT^src{{[/\\]}}t.c
14+
// CHECK: ROOT^src{{[/\\]}}top.h
15+
// CHECK: ROOT^tc{{[/\\]}}lib{{[/\\]}}clang{{[/\\]}}{{.*}}{{[/\\]}}include{{[/\\]}}stdarg.h
16+
// CHECK: ROOT^sdk{{[/\\]}}usr{{[/\\]}}include{{[/\\]}}stdlib.h
1717

1818
// RUN: clang-scan-deps -compilation-database %t/cdb.json \
1919
// RUN: -format experimental-include-tree-full -cas-path %t/cas \
20-
// RUN: -prefix-map=%t=/^src -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc > %t/deps.json
20+
// RUN: -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc > %t/deps.json
2121

2222
// RUN: cat %t/result.txt > %t/full.txt
2323
// RUN: echo "FULL DEPS START" >> %t/full.txt
24-
// RUN: cat %t/deps.json | sed 's:\\\\\?:/:g' >> %t/full.txt
24+
// RUN: cat %t/deps.json >> %t/full.txt
2525

26-
// RUN: FileCheck %s -DPREFIX=%/t -DSDK_PREFIX=%S/Inputs/SDK -check-prefix=FULL -input-file %t/full.txt
26+
// RUN: cat %t/full.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t --sanitize SDK_PREFIX=%/S/Inputs/SDK --sanitize ROOT^=%/root^ --enable-yaml-compatibility %s -check-prefix=FULL
2727

2828
// Capture the tree id from experimental-include-tree ; ensure that it matches
2929
// the result from experimental-full.
30-
// FULL: [[TREE_ID:llvmcas://[[:xdigit:]]+]] - [[PREFIX]]/t.c
30+
// FULL: [[TREE_ID:llvmcas://[[:xdigit:]]+]] - PREFIX{{/|\\}}t.c
3131
// FULL: FULL DEPS START
3232

3333
// FULL-NEXT: {
@@ -40,7 +40,7 @@
4040
// FULL: "command-line": [
4141
// FULL-NEXT: "-cc1"
4242
// FULL: "-fcas-path"
43-
// FULL-NEXT: "[[PREFIX]]/cas"
43+
// FULL-NEXT: "PREFIX{{/|\\\\}}cas"
4444
// FULL: "-disable-free"
4545
// FULL: "-fcas-include-tree"
4646
// FULL-NEXT: "[[TREE_ID]]"
@@ -49,15 +49,15 @@
4949
// FULL: "-x"
5050
// FULL-NEXT: "c"
5151
// FULL: "-isysroot"
52-
// FULL-NEXT: "/^sdk"
52+
// FULL-NEXT: "ROOT^sdk"
5353
// FULL: ]
5454
// FULL: "file-deps": [
55-
// FULL-DAG: "[[PREFIX]]/t.c"
56-
// FULL-DAG: "[[PREFIX]]/top.h"
57-
// FULL-DAG: "{{.*}}/stdarg.h"
58-
// FULL-DAG: "[[SDK_PREFIX]]/usr/include/stdlib.h"
55+
// FULL-DAG: "PREFIX{{/|\\\\}}t.c"
56+
// FULL-DAG: "PREFIX{{/|\\\\}}top.h"
57+
// FULL-DAG: "{{.*}}{{/|\\\\}}stdarg.h"
58+
// FULL-DAG: "SDK_PREFIX{{/|\\\\}}usr{{/|\\\\}}include{{/|\\\\}}stdlib.h"
5959
// FULL: ]
60-
// FULL: "input-file": "[[PREFIX]]/t.c"
60+
// FULL: "input-file": "PREFIX{{/|\\\\}}t.c"
6161
// FULL: }
6262
// FULL: ]
6363
// FULL: }

clang/test/ClangScanDeps/modules-cas-fs-prefix-mapping-caching.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
// RUN: rm -rf %t
66
// RUN: split-file %s %t
77
// RUN: cp -r %t/dir1 %t/dir2
8-
// RUN: sed -e "s|DIR|%t/dir1|g" -e "s|CLANG|%clang|g" -e "s|SDK|%S/Inputs/SDK|g" %t/cdb.json.template > %t/dir1/cdb.json
9-
// RUN: sed -e "s|DIR|%t/dir2|g" -e "s|CLANG|%clang|g" -e "s|SDK|%S/Inputs/SDK|g" %t/cdb.json.template > %t/dir2/cdb.json
8+
// RUN: sed -e "s|DIR|%/t/dir1|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb.json.template > %t/dir1/cdb.json
9+
// RUN: sed -e "s|DIR|%/t/dir2|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb.json.template > %t/dir2/cdb.json
1010

1111
// RUN: clang-scan-deps -compilation-database %t/dir1/cdb.json -format experimental-full \
1212
// RUN: -cas-path %t/cas -module-files-dir %t/dir1/modules \
13-
// RUN: -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc \
14-
// RUN: -prefix-map=%t/dir1/modules=/^modules -prefix-map=%t/dir1=/^src -optimize-args=none \
13+
// RUN: -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \
14+
// RUN: -prefix-map=%t/dir1/modules=%/root^modules -prefix-map=%t/dir1=%/root^src -optimize-args=none \
1515
// RUN: > %t/dir1.txt
1616

1717
// RUN: clang-scan-deps -compilation-database %t/dir2/cdb.json -format experimental-full \
1818
// RUN: -cas-path %t/cas -module-files-dir %t/dir2/modules \
19-
// RUN: -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc \
20-
// RUN: -prefix-map=%t/dir2/modules=/^modules -prefix-map=%t/dir2=/^src -optimize-args=none \
19+
// RUN: -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \
20+
// RUN: -prefix-map=%t/dir2/modules=%/root^modules -prefix-map=%t/dir2=%/root^src -optimize-args=none \
2121
// RUN: > %t/dir2.txt
2222

2323
// Extract individual commands.
@@ -29,15 +29,21 @@
2929
// RUN: %deps-to-rsp %t/dir2.txt --module-name=A > %t/dir2/A.cc1.rsp
3030
// RUN: %deps-to-rsp %t/dir2.txt --tu-index 0 > %t/dir2/tu.cc1.rsp
3131

32-
// RUN: (cd %t/dir1; %clang @B.cc1.rsp) 2>&1 | FileCheck %s -check-prefix=CACHE-MISS
33-
// RUN: (cd %t/dir1; %clang @A.cc1.rsp) 2>&1 | FileCheck %s -check-prefix=CACHE-MISS
34-
// RUN: (cd %t/dir1; %clang @tu.cc1.rsp) 2>&1 | FileCheck %s -check-prefix=CACHE-MISS
32+
// RUN: cd %t/dir1 && %clang @B.cc1.rsp > %t/miss-B.txt 2>&1
33+
// RUN: cat %t/miss-B.txt | FileCheck %s -check-prefix=CACHE-MISS
34+
// RUN: cd %t/dir1 && %clang @A.cc1.rsp > %t/miss-A.txt 2>&1
35+
// RUN: cat %t/miss-A.txt | FileCheck %s -check-prefix=CACHE-MISS
36+
// RUN: cd %t/dir1 && %clang @tu.cc1.rsp > %t/miss-tu.txt 2>&1
37+
// RUN: cat %t/miss-tu.txt | FileCheck %s -check-prefix=CACHE-MISS
3538

3639
// CACHE-MISS: compile job cache miss
3740

38-
// RUN: (cd %t/dir2; %clang @B.cc1.rsp) 2>&1 | FileCheck %s -check-prefix=CACHE-HIT
39-
// RUN: (cd %t/dir2; %clang @A.cc1.rsp) 2>&1 | FileCheck %s -check-prefix=CACHE-HIT
40-
// RUN: (cd %t/dir2; %clang @tu.cc1.rsp) 2>&1 | FileCheck %s -check-prefix=CACHE-HIT
41+
// RUN: cd %t/dir2 && %clang @B.cc1.rsp > %t/hit-B.txt 2>&1
42+
// RUN: cat %t/hit-B.txt | FileCheck %s -check-prefix=CACHE-HIT
43+
// RUN: cd %t/dir2 && %clang @A.cc1.rsp > %t/hit-A.txt 2>&1
44+
// RUN: cat %t/hit-B.txt | FileCheck %s -check-prefix=CACHE-HIT
45+
// RUN: cd %t/dir2 && %clang @tu.cc1.rsp > %t/hit-tu.txt 2>&1
46+
// RUN: cat %t/hit-tu.txt | FileCheck %s -check-prefix=CACHE-HIT
4147

4248
// CACHE-HIT: compile job cache hit
4349

0 commit comments

Comments
 (0)