Skip to content

Commit 152cf61

Browse files
authored
Implement more precise path matching in some CAS tests (#11262)
1 parent 16bb3dc commit 152cf61

File tree

9 files changed

+235
-105
lines changed

9 files changed

+235
-105
lines changed

clang/test/ClangScanDeps/include-tree.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@
3434

3535
// RUN: cat %t/result1.txt > %t/full.txt
3636
// RUN: echo "FULL DEPS START" >> %t/full.txt
37-
// RUN: cat %t/deps.json | sed 's:\\\\\?:/:g' >> %t/full.txt
37+
// RUN: cat %t/deps.json >> %t/full.txt
3838

39-
// RUN: FileCheck %s -DPREFIX=%/t -DCLANG=%clang -check-prefix=FULL -input-file %t/full.txt
39+
// RUN: cat %t/full.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t --sanitize CLANG=%/clang --enable-yaml-compatibility %s -check-prefix=FULL
4040

4141
// Capture the tree id from experimental-include-tree ; ensure that it matches
4242
// the result from experimental-full.
43-
// FULL: [[TREE_ID:llvmcas://[[:xdigit:]]+]] - [[PREFIX]]{{[/\\]}}t.c
43+
// FULL: [[TREE_ID:llvmcas://[[:xdigit:]]+]] - PREFIX{{/|\\}}t.c
4444
// FULL: FULL DEPS START
4545

4646
// FULL-NEXT: {
@@ -54,7 +54,7 @@
5454
// FULL: "command-line": [
5555
// FULL-NEXT: "-cc1"
5656
// FULL: "-fcas-path"
57-
// FULL-NEXT: "[[PREFIX]]/cas"
57+
// FULL-NEXT: "PREFIX{{/|\\\\}}cas"
5858
// FULL: "-disable-free"
5959
// FULL: "-fcas-include-tree"
6060
// FULL-NEXT: "[[TREE_ID]]"
@@ -67,17 +67,17 @@
6767
// FULL-NEXT: "t.c"
6868
// FULL-NOT: "t.c"
6969
// FULL: ]
70-
// FULL: "{{.*[\\/]clang(\.exe)?}}",
70+
// FULL: "executable": "CLANG",
7171
// FULL: "file-deps": [
72-
// FULL-NEXT: "[[PREFIX]]/t.c"
73-
// FULL-NEXT: "[[PREFIX]]/top.h"
74-
// FULL-NEXT: "[[PREFIX]]/n1.h"
75-
// FULL-NEXT: "[[PREFIX]]/n2.h"
76-
// FULL-NEXT: "[[PREFIX]]/n3.h"
77-
// FULL-NEXT: "[[PREFIX]]/n3.h"
78-
// FULL-NEXT: "[[PREFIX]]/n2.h"
72+
// FULL-NEXT: "PREFIX{{/|\\\\}}t.c"
73+
// FULL-NEXT: "PREFIX{{/|\\\\}}top.h"
74+
// FULL-NEXT: "PREFIX{{/|\\\\}}n1.h"
75+
// FULL-NEXT: "PREFIX{{/|\\\\}}n2.h"
76+
// FULL-NEXT: "PREFIX{{/|\\\\}}n3.h"
77+
// FULL-NEXT: "PREFIX{{/|\\\\}}n3.h"
78+
// FULL-NEXT: "PREFIX{{/|\\\\}}n2.h"
7979
// FULL-NEXT: ]
80-
// FULL: "input-file": "[[PREFIX]]/t.c"
80+
// FULL: "input-file": "PREFIX{{/|\\\\}}t.c"
8181
// FULL: }
8282
// FULL: ]
8383
// FULL: }

clang/test/ClangScanDeps/modules-cas-context-hash.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// RUN: -cas-path %t/cas2 -format experimental-include-tree-full \
1313
// RUN: >> %t/result.json
1414

15-
// RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
15+
// RUN: cat %t/result.json | %PathSanitizingFileCheck --sanitize PREFIX=%/t --enable-yaml-compatibility %s
1616

1717
// CHECK: "modules": [
1818
// CHECK: {
@@ -33,7 +33,7 @@
3333
// CHECK: ],
3434
// CHECK: "command-line": [
3535
// CHECK: "-fmodule-file-cache-key"
36-
// CHECK: "[[PREFIX]]/outputs/[[HASH]]/Mod-[[HASH]].pcm"
36+
// CHECK: "PREFIX{{/|\\\\}}outputs{{/|\\\\}}[[HASH]]{{/|\\\\}}Mod-[[HASH]].pcm"
3737
// CHECK: "llvmcas://[[KEY]]"
3838
// CHECK: ]
3939

@@ -57,7 +57,7 @@
5757
// CHECK: ],
5858
// CHECK: "command-line": [
5959
// CHECK: "-fmodule-file-cache-key"
60-
// CHECK: "[[PREFIX]]/outputs/[[HASH]]/Mod-[[HASH]].pcm"
60+
// CHECK: "PREFIX{{/|\\\\}}outputs{{/|\\\\}}[[HASH]]{{/|\\\\}}Mod-[[HASH]].pcm"
6161
// CHECK: "llvmcas://[[KEY]]"
6262
// CHECK: ]
6363

clang/test/ClangScanDeps/modules-cas-full-by-mod-name.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module transitive { header "transitive.h" }
3030
// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
3131
// RUN: clang-scan-deps -compilation-database %t/cdb.json \
3232
// RUN: -cas-path %t/cas -format experimental-full -module-name=root > %t/result.json
33-
// RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t %s
33+
// RUN: cat %t/result.json | %PathSanitizingFileCheck --sanitize PREFIX=%/t --enable-yaml-compatibility %s
3434

3535
// CHECK: {
3636
// CHECK-NEXT: "modules": [
@@ -43,16 +43,16 @@ module transitive { header "transitive.h" }
4343
// CHECK-NEXT: "module-name": "transitive"
4444
// CHECK-NEXT: }
4545
// CHECK-NEXT: ],
46-
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
46+
// CHECK-NEXT: "clang-modulemap-file": "PREFIX{{/|\\\\}}module.modulemap",
4747
// CHECK-NEXT: "command-line": [
4848
// CHECK: "-fmodule-file-cache-key"
4949
// CHECK-NEXT: "{{.*transitive-.*\.pcm}}"
5050
// CHECK-NEXT: "[[TRANSITIVE_CACHE_KEY:llvmcas://[[:xdigit:]]+]]"
5151
// CHECK: ],
5252
// CHECK-NEXT: "context-hash": "{{.*}}",
5353
// CHECK-NEXT: "file-deps": [
54-
// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
55-
// CHECK-NEXT: "[[PREFIX]]/direct.h"
54+
// CHECK-NEXT: "PREFIX{{/|\\\\}}module.modulemap"
55+
// CHECK-NEXT: "PREFIX{{/|\\\\}}direct.h"
5656
// CHECK-NEXT: ],
5757
// CHECK-NEXT: "link-libraries": [],
5858
// CHECK-NEXT: "name": "direct"
@@ -66,17 +66,17 @@ module transitive { header "transitive.h" }
6666
// CHECK-NEXT: "module-name": "direct"
6767
// CHECK-NEXT: }
6868
// CHECK-NEXT: ],
69-
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
69+
// CHECK-NEXT: "clang-modulemap-file": "PREFIX{{/|\\\\}}module.modulemap",
7070
// CHECK-NEXT: "command-line": [
7171
// CHECK: "-fmodule-file-cache-key"
7272
// CHECK-NEXT: "{{.*direct-.*\.pcm}}"
7373
// CHECK-NEXT: "[[DIRECT_CACHE_KEY]]"
7474
// CHECK: ],
7575
// CHECK-NEXT: "context-hash": "{{.*}}",
7676
// CHECK-NEXT: "file-deps": [
77-
// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
78-
// CHECK-NEXT: "[[PREFIX]]/root.h"
79-
// CHECK-NEXT: "[[PREFIX]]/root/textual.h"
77+
// CHECK-NEXT: "PREFIX{{/|\\\\}}module.modulemap"
78+
// CHECK-NEXT: "PREFIX{{/|\\\\}}root.h"
79+
// CHECK-NEXT: "PREFIX{{/|\\\\}}root{{/|\\\\}}textual.h"
8080
// CHECK-NEXT: ],
8181
// CHECK-NEXT: "link-libraries": [],
8282
// CHECK-NEXT: "name": "root"
@@ -85,13 +85,13 @@ module transitive { header "transitive.h" }
8585
// CHECK-NEXT: "cache-key": "[[TRANSITIVE_CACHE_KEY]]"
8686
// CHECK-NEXT: "casfs-root-id": "[[LEFT_ROOT_ID]]"
8787
// CHECK-NEXT: "clang-module-deps": [],
88-
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
88+
// CHECK-NEXT: "clang-modulemap-file": "PREFIX{{/|\\\\}}module.modulemap",
8989
// CHECK-NEXT: "command-line": [
9090
// CHECK: ],
9191
// CHECK-NEXT: "context-hash": "{{.*}}",
9292
// CHECK-NEXT: "file-deps": [
93-
// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
94-
// CHECK-NEXT: "[[PREFIX]]/transitive.h"
93+
// CHECK-NEXT: "PREFIX{{/|\\\\}}module.modulemap"
94+
// CHECK-NEXT: "PREFIX{{/|\\\\}}transitive.h"
9595
// CHECK-NEXT: ],
9696
// CHECK-NEXT: "link-libraries": [],
9797
// CHECK-NEXT: "name": "transitive"

clang/test/ClangScanDeps/modules-include-tree-submodules.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
// RUN: echo "TRANSLATION UNIT 2" >> %t/result.txt
3131
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu2.casid >> %t/result.txt
3232

33-
// RUN: cat %t/result.txt | sed 's/\\/\//g' | FileCheck %s -DPREFIX=%/t
33+
// RUN: cat %t/result.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t %s
3434

3535
// Build the include-tree commands
3636
// RUN: %clang @%t/TwoSubs.rsp
@@ -39,27 +39,27 @@
3939
// RUN: not %clang @%t/tu2.rsp 2>&1 | FileCheck %s -check-prefix=TU2
4040

4141
// CHECK: MODULE TwoSubs
42-
// CHECK: 2:1 [[PREFIX]]/Sub1.h llvmcas://{{[[:xdigit:]]+}}
42+
// CHECK: 2:1 PREFIX{{/|\\}}Sub1.h llvmcas://{{[[:xdigit:]]+}}
4343
// CHECK: Submodule: TwoSubs.Sub1
44-
// CHECK: 3:1 [[PREFIX]]/Sub2.h llvmcas://{{[[:xdigit:]]+}}
44+
// CHECK: 3:1 PREFIX{{/|\\}}Sub2.h llvmcas://{{[[:xdigit:]]+}}
4545
// CHECK: Submodule: TwoSubs.Sub2
4646

4747
// CHECK: MODULE WithExplicit
48-
// CHECK: 2:1 [[PREFIX]]/TopLevel.h llvmcas://{{[[:xdigit:]]+}}
48+
// CHECK: 2:1 PREFIX{{/|\\}}TopLevel.h llvmcas://{{[[:xdigit:]]+}}
4949
// CHECK: Submodule: WithExplicit
50-
// CHECK: 3:1 [[PREFIX]]/Implicit.h llvmcas://{{[[:xdigit:]]+}}
50+
// CHECK: 3:1 PREFIX{{/|\\}}Implicit.h llvmcas://{{[[:xdigit:]]+}}
5151
// CHECK: Submodule: WithExplicit.Implicit
52-
// CHECK: 4:1 [[PREFIX]]/Explicit.h llvmcas://{{[[:xdigit:]]+}}
52+
// CHECK: 4:1 PREFIX{{/|\\}}Explicit.h llvmcas://{{[[:xdigit:]]+}}
5353
// CHECK: Submodule: WithExplicit.Explicit
5454

5555
// CHECK: TRANSLATION UNIT 1
56-
// CHECK: [[PREFIX]]/tu1.c llvmcas://{{[[:xdigit:]]+}}
56+
// CHECK: PREFIX{{/|\\}}tu1.c llvmcas://{{[[:xdigit:]]+}}
5757
// CHECK: 1:1 <built-in> llvmcas://{{[[:xdigit:]]+}}
5858
// CHECK: 2:1 (Module) TwoSubs.Sub1
5959
// CHECK: 3:1 (Module) WithExplicit
6060

6161
// CHECK: TRANSLATION UNIT 2
62-
// CHECK: [[PREFIX]]/tu2.c llvmcas://{{[[:xdigit:]]+}}
62+
// CHECK: PREFIX{{/|\\}}tu2.c llvmcas://{{[[:xdigit:]]+}}
6363
// CHECK: 1:1 <built-in> llvmcas://{{[[:xdigit:]]+}}
6464
// CHECK: 2:1 (Module) TwoSubs.Sub2
6565
// CHECK: 3:1 (Module) WithExplicit.Explicit

clang/test/ClangScanDeps/modules-include-tree-with-pch.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,28 @@
3434
// RUN: rm -rf %t/outputs
3535
// RUN: %clang @%t/tu.rsp
3636

37-
// RUN: cat %t/deps.json | sed 's/\\\\/\//g' | FileCheck %s -DPREFIX=%/t
37+
// RUN: cat %t/deps.json | %PathSanitizingFileCheck --sanitize PREFIX=%/t --enable-yaml-compatibility %s
3838

3939
// CHECK: {
4040
// CHECK-NEXT: "modules": [
4141
// CHECK-NEXT: {
4242
// CHECK: "clang-module-deps": []
43-
// CHECK: "clang-modulemap-file": "[[PREFIX]]/module.modulemap"
43+
// CHECK: "clang-modulemap-file": "PREFIX{{/|\\\\}}module.modulemap"
4444
// CHECK: "command-line": [
4545
// CHECK-NEXT: "-cc1"
4646
// CHECK: "-fcas-path"
47-
// CHECK-NEXT: "[[PREFIX]]/cas"
47+
// CHECK-NEXT: "PREFIX{{/|\\\\}}cas"
4848
// CHECK: "-o"
49-
// CHECK-NEXT: "[[PREFIX]]/outputs/{{.*}}/Right-{{.*}}.pcm"
49+
// CHECK-NEXT: "PREFIX{{/|\\\\}}outputs{{/|\\\\}}{{.*}}{{/|\\\\}}Right-{{.*}}.pcm"
5050
// CHECK: "-disable-free"
5151
// CHECK: "-fno-pch-timestamp"
5252
// CHECK: "-fcas-include-tree"
5353
// CHECK-NEXT: "[[RIGHT_TREE:llvmcas://[[:xdigit:]]+]]"
5454
// CHECK: "-fcache-compile-job"
5555
// CHECK: "-emit-module"
56-
// CHECK: "-fmodule-file=[[PREFIX]]/outputs/{{.*}}/Top-{{.*}}.pcm"
56+
// CHECK: "-fmodule-file=PREFIX{{/|\\\\}}outputs{{/|\\\\}}{{.*}}{{/|\\\\}}Top-{{.*}}.pcm"
5757
// CHECK: "-fmodule-file-cache-key"
58-
// CHECK-NEXT: "[[PREFIX]]/{{.*}}/Top-{{.*}}.pcm"
58+
// CHECK-NEXT: "PREFIX{{/|\\\\}}{{.*}}{{/|\\\\}}Top-{{.*}}.pcm"
5959
// CHECK-NEXT: "llvmcas://{{[[:xdigit:]]+}}"
6060
// CHECK: "-x"
6161
// CHECK-NEXT: "c"
@@ -64,8 +64,8 @@
6464
// CHECK: "-fno-implicit-modules"
6565
// CHECK: ]
6666
// CHECK: "file-deps": [
67-
// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
68-
// CHECK-NEXT: "[[PREFIX]]/Right.h"
67+
// CHECK-NEXT: "PREFIX{{/|\\\\}}module.modulemap"
68+
// CHECK-NEXT: "PREFIX{{/|\\\\}}Right.h"
6969
// CHECK-NEXT: ]
7070
// CHECK: "name": "Right"
7171
// CHECK: }
@@ -83,27 +83,27 @@
8383
// CHECK: "command-line": [
8484
// CHECK-NEXT: "-cc1"
8585
// CHECK: "-fcas-path"
86-
// CHECK-NEXT: "[[PREFIX]]/cas"
86+
// CHECK-NEXT: "PREFIX{{/|\\\\}}cas"
8787
// CHECK-NOT: -fmodule-map-file=
8888
// CHECK: "-disable-free"
8989
// CHECK: "-fcas-include-tree"
9090
// CHECK-NEXT: "llvmcas://{{[[:xdigit:]]+}}"
9191
// CHECK: "-fcache-compile-job"
9292
// CHECK: "-fsyntax-only"
9393
// CHECK: "-fmodule-file-cache-key"
94-
// CHECK-NEXT: "[[PREFIX]]/outputs/{{.*}}/Right-{{.*}}.pcm"
94+
// CHECK-NEXT: "PREFIX{{/|\\\\}}outputs{{/|\\\\}}{{.*}}{{/|\\\\}}Right-{{.*}}.pcm"
9595
// CHECK-NEXT: "llvmcas://{{[[:xdigit:]]+}}"
9696
// CHECK: "-x"
9797
// CHECK-NEXT: "c"
98-
// CHECK: "-fmodule-file=Right=[[PREFIX]]/outputs/{{.*}}/Right-{{.*}}.pcm"
98+
// CHECK: "-fmodule-file=Right=PREFIX{{/|\\\\}}outputs{{/|\\\\}}{{.*}}{{/|\\\\}}Right-{{.*}}.pcm"
9999
// CHECK: "-fmodules"
100100
// CHECK: "-fno-implicit-modules"
101101
// CHECK: ]
102102
// CHECK: "file-deps": [
103-
// CHECK-NEXT: "[[PREFIX]]/tu.c"
104-
// CHECK-NEXT: "[[PREFIX]]/prefix.h.pch"
103+
// CHECK-NEXT: "PREFIX{{/|\\\\}}tu.c"
104+
// CHECK-NEXT: "PREFIX{{/|\\\\}}prefix.h.pch"
105105
// CHECK-NEXT: ]
106-
// CHECK: "input-file": "[[PREFIX]]/tu.c"
106+
// CHECK: "input-file": "PREFIX{{/|\\\\}}tu.c"
107107
// CHECK: }
108108
// CHECK-NEXT: ]
109109
// CHECK-NEXT: }

0 commit comments

Comments
 (0)