Skip to content

Commit 67f3a25

Browse files
committed
Improve test
1 parent 306a9ce commit 67f3a25

File tree

1 file changed

+116
-14
lines changed

1 file changed

+116
-14
lines changed

clang/test/ClangScanDeps/modules-pch-common-stale.c

Lines changed: 116 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,51 +27,153 @@ module mod_tu_extra { header "mod_tu_extra.h" }
2727
#include "mod_tu.h"
2828

2929
// Clean: scan the PCH.
30-
// RUN: clang-scan-deps -format experimental-full -o %t/deps_pch.json -- \
30+
// RUN: clang-scan-deps -format experimental-full -o %t/deps_pch_clean.json -- \
3131
// RUN: %clang -x c-header %t/prefix.h -o %t/prefix.h.pch -F %t \
3232
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache
3333

3434
// Clean: build the PCH.
35-
// RUN: %deps-to-rsp %t/deps_pch.json --module-name mod_common > %t/mod_common.rsp
36-
// RUN: %deps-to-rsp %t/deps_pch.json --tu-index 0 > %t/pch.rsp
35+
// RUN: %deps-to-rsp %t/deps_pch_clean.json --module-name mod_common > %t/mod_common.rsp
36+
// RUN: %deps-to-rsp %t/deps_pch_clean.json --tu-index 0 > %t/pch.rsp
3737
// RUN: %clang @%t/mod_common.rsp
3838
// RUN: %clang @%t/pch.rsp
3939

4040
// Clean: scan the TU.
41-
// RUN: clang-scan-deps -format experimental-full -o %t/deps_tu.json -- \
41+
// RUN: clang-scan-deps -format experimental-full -o %t/deps_tu_clean.json -- \
4242
// RUN: %clang -c %t/tu.c -o %t/tu.o -include %t/prefix.h -F %t \
4343
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache
44+
// RUN: FileCheck --input-file=%t/deps_tu_clean.json %s --check-prefix=CHECK-TU-CLEAN -DPREFIX=%/t
45+
// CHECK-TU-CLEAN: {
46+
// CHECK-TU-CLEAN-NEXT: "modules": [
47+
// CHECK-TU-CLEAN-NEXT: {
48+
// CHECK-TU-CLEAN-NEXT: "clang-module-deps": [],
49+
// CHECK-TU-CLEAN-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
50+
// CHECK-TU-CLEAN-NEXT: "command-line": [
51+
// CHECK-TU-CLEAN: ],
52+
// CHECK-TU-CLEAN-NEXT: "context-hash": "{{.*}}",
53+
// CHECK-TU-CLEAN-NEXT: "file-deps": [
54+
// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/module.modulemap",
55+
// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/mod_tu.h"
56+
// CHECK-TU-CLEAN-NEXT: ],
57+
// CHECK-TU-CLEAN-NEXT: "link-libraries": [],
58+
// CHECK-TU-CLEAN-NEXT: "name": "mod_tu"
59+
// CHECK-TU-CLEAN-NEXT: }
60+
// CHECK-TU-CLEAN-NEXT: ],
61+
// CHECK-TU-CLEAN-NEXT: "translation-units": [
62+
// CHECK-TU-CLEAN-NEXT: {
63+
// CHECK-TU-CLEAN-NEXT: "commands": [
64+
// CHECK-TU-CLEAN-NEXT: {
65+
// CHECK-TU-CLEAN-NEXT: "clang-context-hash": "{{.*}}",
66+
// CHECK-TU-CLEAN-NEXT: "clang-module-deps": [
67+
// CHECK-TU-CLEAN-NEXT: {
68+
// CHECK-TU-CLEAN-NEXT: "context-hash": "{{.*}}",
69+
// CHECK-TU-CLEAN-NEXT: "module-name": "mod_tu"
70+
// CHECK-TU-CLEAN-NEXT: }
71+
// CHECK-TU-CLEAN-NEXT: ],
72+
// CHECK-TU-CLEAN-NEXT: "command-line": [
73+
// CHECK-TU-CLEAN: ],
74+
// CHECK-TU-CLEAN-NEXT: "executable": "{{.*}}",
75+
// CHECK-TU-CLEAN-NEXT: "file-deps": [
76+
// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/tu.c",
77+
// CHECK-TU-CLEAN-NEXT: "[[PREFIX]]/prefix.h.pch"
78+
// CHECK-TU-CLEAN-NEXT: ],
79+
// CHECK-TU-CLEAN-NEXT: "input-file": "[[PREFIX]]/tu.c"
80+
// CHECK-TU-CLEAN-NEXT: }
81+
// CHECK-TU-CLEAN-NEXT: ]
82+
// CHECK-TU-CLEAN-NEXT: }
83+
// CHECK-TU-CLEAN: ]
84+
// CHECK-TU-CLEAN: }
4485

4586
// Clean: build the TU.
46-
// RUN: %deps-to-rsp %t/deps_tu.json --module-name mod_tu > %t/mod_tu.rsp
47-
// RUN: %deps-to-rsp %t/deps_tu.json --tu-index 0 > %t/tu.rsp
87+
// RUN: %deps-to-rsp %t/deps_tu_clean.json --module-name mod_tu > %t/mod_tu.rsp
88+
// RUN: %deps-to-rsp %t/deps_tu_clean.json --tu-index 0 > %t/tu.rsp
4889
// RUN: %clang @%t/mod_tu.rsp
4990
// RUN: %clang @%t/tu.rsp
5091

5192
// Incremental: modify the common module.
93+
// RUN: sleep 1
5294
// RUN: echo "#define MOD_COMMON_MACRO 1" > %t/mod_common.h
5395

5496
// Incremental: scan the PCH.
55-
// RUN: clang-scan-deps -format experimental-full -o %t/deps_pch.json -- \
97+
// RUN: clang-scan-deps -format experimental-full -o %t/deps_pch_incremental.json -- \
5698
// RUN: %clang -x c-header %t/prefix.h -o %t/prefix.h.pch -F %t \
5799
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache
58100

59101
// Incremental: build the PCH.
60-
// RUN: %deps-to-rsp %t/deps_pch.json --module-name mod_common > %t/mod_common.rsp
61-
// RUN: %deps-to-rsp %t/deps_pch.json --tu-index 0 > %t/pch.rsp
102+
// RUN: %deps-to-rsp %t/deps_pch_incremental.json --module-name mod_common > %t/mod_common.rsp
103+
// RUN: %deps-to-rsp %t/deps_pch_incremental.json --tu-index 0 > %t/pch.rsp
62104
// RUN: %clang @%t/mod_common.rsp
63105
// RUN: %clang @%t/pch.rsp
64106

65107
// Incremental: scan the TU. This needs to invalidate modules imported from the
66-
// TU that depend on modules imported from the PCH.
67-
// RUN: clang-scan-deps -format experimental-full -o %t/deps_tu.json -- \
108+
// TU that depend on modules imported from the PCH and discover the
109+
// new dependency on 'mod_tu_extra'.
110+
// RUN: clang-scan-deps -format experimental-full -o %t/deps_tu_incremental.json -- \
68111
// RUN: %clang -c %t/tu.c -o %t/tu.o -include %t/prefix.h -F %t \
69112
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache
113+
// RUN: FileCheck --input-file=%t/deps_tu_incremental.json %s --check-prefix=CHECK-TU-INCREMENTAL -DPREFIX=%/t
114+
// CHECK-TU-INCREMENTAL: {
115+
// CHECK-TU-INCREMENTAL-NEXT: "modules": [
116+
// CHECK-TU-INCREMENTAL-NEXT: {
117+
// CHECK-TU-INCREMENTAL-NEXT: "clang-module-deps": [
118+
// CHECK-TU-INCREMENTAL-NEXT: {
119+
// CHECK-TU-INCREMENTAL-NEXT: "context-hash": "{{.*}}",
120+
// CHECK-TU-INCREMENTAL-NEXT: "module-name": "mod_tu_extra"
121+
// CHECK-TU-INCREMENTAL-NEXT: }
122+
// CHECK-TU-INCREMENTAL-NEXT: ],
123+
// CHECK-TU-INCREMENTAL-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
124+
// CHECK-TU-INCREMENTAL-NEXT: "command-line": [
125+
// CHECK-TU-INCREMENTAL: ],
126+
// CHECK-TU-INCREMENTAL-NEXT: "context-hash": "{{.*}}",
127+
// CHECK-TU-INCREMENTAL-NEXT: "file-deps": [
128+
// CHECK-TU-INCREMENTAL-NEXT: "[[PREFIX]]/module.modulemap",
129+
// CHECK-TU-INCREMENTAL-NEXT: "[[PREFIX]]/mod_tu.h"
130+
// CHECK-TU-INCREMENTAL-NEXT: ],
131+
// CHECK-TU-INCREMENTAL-NEXT: "link-libraries": [],
132+
// CHECK-TU-INCREMENTAL-NEXT: "name": "mod_tu"
133+
// CHECK-TU-INCREMENTAL-NEXT: },
134+
// CHECK-TU-INCREMENTAL-NEXT: {
135+
// CHECK-TU-INCREMENTAL-NEXT: "clang-module-deps": [],
136+
// CHECK-TU-INCREMENTAL-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
137+
// CHECK-TU-INCREMENTAL-NEXT: "command-line": [
138+
// CHECK-TU-INCREMENTAL: ],
139+
// CHECK-TU-INCREMENTAL-NEXT: "context-hash": "{{.*}}",
140+
// CHECK-TU-INCREMENTAL-NEXT: "file-deps": [
141+
// CHECK-TU-INCREMENTAL-NEXT: "[[PREFIX]]/module.modulemap",
142+
// CHECK-TU-INCREMENTAL-NEXT: "[[PREFIX]]/mod_tu_extra.h"
143+
// CHECK-TU-INCREMENTAL-NEXT: ],
144+
// CHECK-TU-INCREMENTAL-NEXT: "link-libraries": [],
145+
// CHECK-TU-INCREMENTAL-NEXT: "name": "mod_tu_extra"
146+
// CHECK-TU-INCREMENTAL-NEXT: }
147+
// CHECK-TU-INCREMENTAL-NEXT: ],
148+
// CHECK-TU-INCREMENTAL-NEXT: "translation-units": [
149+
// CHECK-TU-INCREMENTAL-NEXT: {
150+
// CHECK-TU-INCREMENTAL-NEXT: "commands": [
151+
// CHECK-TU-INCREMENTAL-NEXT: {
152+
// CHECK-TU-INCREMENTAL-NEXT: "clang-context-hash": "{{.*}}",
153+
// CHECK-TU-INCREMENTAL-NEXT: "clang-module-deps": [
154+
// CHECK-TU-INCREMENTAL-NEXT: {
155+
// CHECK-TU-INCREMENTAL-NEXT: "context-hash": "{{.*}}",
156+
// CHECK-TU-INCREMENTAL-NEXT: "module-name": "mod_tu"
157+
// CHECK-TU-INCREMENTAL-NEXT: }
158+
// CHECK-TU-INCREMENTAL-NEXT: ],
159+
// CHECK-TU-INCREMENTAL-NEXT: "command-line": [
160+
// CHECK-TU-INCREMENTAL: ],
161+
// CHECK-TU-INCREMENTAL-NEXT: "executable": "{{.*}}",
162+
// CHECK-TU-INCREMENTAL-NEXT: "file-deps": [
163+
// CHECK-TU-INCREMENTAL-NEXT: "[[PREFIX]]/tu.c",
164+
// CHECK-TU-INCREMENTAL-NEXT: "[[PREFIX]]/prefix.h.pch"
165+
// CHECK-TU-INCREMENTAL-NEXT: ],
166+
// CHECK-TU-INCREMENTAL-NEXT: "input-file": "[[PREFIX]]/tu.c"
167+
// CHECK-TU-INCREMENTAL-NEXT: }
168+
// CHECK-TU-INCREMENTAL-NEXT: ]
169+
// CHECK-TU-INCREMENTAL-NEXT: }
170+
// CHECK-TU-INCREMENTAL: ]
171+
// CHECK-TU-INCREMENTAL: }
70172

71173
// Incremental: build the TU.
72-
// RUN: %deps-to-rsp %t/deps_tu.json --module-name mod_tu_extra > %t/mod_tu_extra.rsp
73-
// RUN: %deps-to-rsp %t/deps_tu.json --module-name mod_tu > %t/mod_tu.rsp
74-
// RUN: %deps-to-rsp %t/deps_tu.json --tu-index 0 > %t/tu.rsp
174+
// RUN: %deps-to-rsp %t/deps_tu_incremental.json --module-name mod_tu_extra > %t/mod_tu_extra.rsp
175+
// RUN: %deps-to-rsp %t/deps_tu_incremental.json --module-name mod_tu > %t/mod_tu.rsp
176+
// RUN: %deps-to-rsp %t/deps_tu_incremental.json --tu-index 0 > %t/tu.rsp
75177
// RUN: %clang @%t/mod_tu_extra.rsp
76178
// RUN: %clang @%t/mod_tu.rsp
77179
// RUN: %clang @%t/tu.rsp

0 commit comments

Comments
 (0)