Skip to content

Commit accc647

Browse files
author
Nathan Hawes
committed
[ParseableInterface][test] Update SDKDependencies.swift test to explicitly check serialized dependencies
Also use the existing check-is-forwarding-module.py script to check for forwarding modules, rather than doing it manually.
1 parent 3732802 commit accc647

File tree

2 files changed

+60
-16
lines changed

2 files changed

+60
-16
lines changed

Diff for: lib/Frontend/ParseableInterfaceModuleLoader.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,6 @@ class swift::ParseableInterfaceBuilder {
359359
/// Determines if the dependency with the provided path is a swiftmodule in
360360
/// either the module cache or prebuilt module cache
361361
bool isCachedModule(StringRef DepName) const {
362-
if (moduleCachePath.empty() && prebuiltCachePath.empty())
363-
return false;
364-
365362
auto Ext = llvm::sys::path::extension(DepName);
366363
auto Ty = file_types::lookupTypeForExtension(Ext);
367364

Diff for: test/ParseableInterface/ModuleCache/SDKDependencies.swift

+60-13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@
77
// RUN: %target-swift-frontend -build-module-from-parseable-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/ExportedLib.swiftmodule -track-system-dependencies -module-name ExportedLib %t/my-sdk/ExportedLib.swiftinterface
88
// RUN: %target-swift-frontend -build-module-from-parseable-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/SdkLib.swiftmodule -track-system-dependencies -module-name SdkLib %t/my-sdk/SdkLib.swiftinterface
99
//
10+
// Check the prebuilt modules don't contain dependencies in the module cache or prebuilt cache
11+
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/ExportedLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
12+
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/SdkLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
13+
//
14+
// PREBUILT: MODULE_BLOCK
15+
// PREBUILT-NOT: FILE_DEPENDENCY {{.*}}/MCP/{{.*}}
16+
// PREBUILT-NOT: FILE_DEPENDENCY {{.*}}/prebuilt-cache/{{.*}}
17+
//
18+
// Re-build them in the opposite order
19+
// RUN: %empty-directory(%t/prebuilt-cache)
20+
// RUN: %empty-directory(%t/MCP)
21+
// RUN: %target-swift-frontend -build-module-from-parseable-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/SdkLib.swiftmodule -track-system-dependencies -module-name SdkLib %t/my-sdk/SdkLib.swiftinterface
22+
// RUN: %target-swift-frontend -build-module-from-parseable-interface -serialize-parseable-module-interface-dependency-hashes -sdk %t/my-sdk -prebuilt-module-cache-path %t/prebuilt-cache -I %t/my-sdk -module-cache-path %t/MCP -o %t/prebuilt-cache/ExportedLib.swiftmodule -track-system-dependencies -module-name ExportedLib %t/my-sdk/ExportedLib.swiftinterface
23+
//
24+
// Check they still don't contain dependencies in the module cache or prebuilt cache
25+
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/ExportedLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
26+
// RUN: llvm-bcanalyzer -dump %t/prebuilt-cache/SdkLib.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
27+
//
1028
// RUN: %empty-directory(%t/MCP)
1129
// RUN: echo '1: PASSED'
1230

@@ -20,8 +38,12 @@
2038
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
2139
//
2240
// Check they are *not* forwarding modules
23-
// RUN: head -n 1 %t/MCP/SdkLib-*.swiftmodule | not grep -e '---'
24-
// RUN: head -n 1 %t/MCP/ExportedLib-*.swiftmodule | not grep -e '---'
41+
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
42+
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
43+
//
44+
// Check they don't contain dependencies in the module cache (..or prebuilt cache)
45+
// RUN: llvm-bcanalyzer -dump %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
46+
// RUN: llvm-bcanalyzer -dump %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
2547
//
2648
// RUN: %empty-directory(%t/MCP)
2749
// RUN: echo '2: PASSED'
@@ -36,8 +58,8 @@
3658
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
3759
//
3860
// Check they *are* forwarding modules
39-
// RUN: head -n 1 %t/MCP/SdkLib-*.swiftmodule | grep -e '---'
40-
// RUN: head -n 1 %t/MCP/ExportedLib-*.swiftmodule | grep -e '---'
61+
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
62+
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
4163
//
4264
// Check they contain the expected dependencies
4365
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=EXLIB
@@ -49,23 +71,35 @@
4971
// EXLIB-DAG: /my-sdk/ExportedLib.swiftinterface
5072
// SDKLIB-DAG: /my-sdk/SdkLib.swiftinterface
5173
//
74+
// Check they don't contain any dependencies from either cache other than themselves
75+
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=ExportedLib
76+
// RUN: cat %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=SdkLib
77+
//
78+
// NOCACHE: dependencies:
79+
// NOCACHE-NOT: /prebuilt-cache/
80+
// NOCACHE-NOT: /MCP/
81+
// NOCACHE: /prebuilt-cache/[[LIB_NAME]].swiftmodule
82+
// NOCACHE-NOT: /prebuilt-cache/
83+
// NOCACHE-NOT: /MCP/
84+
//
5285
// RUN: %empty-directory(%t/MCP)
5386
// RUN: echo '3: PASSED'
5487

5588

5689
// 4) Move the SDK without changing its contents
5790
//
5891
// RUN: mv %t/my-sdk %t/my-new-sdk
59-
// RUN: mv %t/prebuilt-cache %t/new-prebuilt-cache
60-
// RUN: %target-swift-frontend -typecheck -I %t/my-new-sdk -sdk %t/my-new-sdk -prebuilt-module-cache-path %t/new-prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
92+
// RUN: mkdir %t/new-dir
93+
// RUN: mv %t/prebuilt-cache %t/new-dir/
94+
// RUN: %target-swift-frontend -typecheck -I %t/my-new-sdk -sdk %t/my-new-sdk -prebuilt-module-cache-path %t/new-dir/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
6195
//
6296
// Check SdkLib and ExportedLib are in the module cache
6397
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
6498
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
6599
//
66100
// Check they are still both forwarding modules
67-
// RUN: head -n 1 %t/MCP/SdkLib-*.swiftmodule | grep -e '---'
68-
// RUN: head -n 1 %t/MCP/ExportedLib-*.swiftmodule | grep -e '---'
101+
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
102+
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
69103
//
70104
// Check they contain the expected dependencies
71105
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NEW-EXLIB
@@ -76,25 +110,34 @@
76110
// NEW-EXLIB-DAG: /my-new-sdk/ExportedLib.swiftinterface
77111
// NEW-SDKLIB-DAG: /my-new-sdk/SdkLib.swiftinterface
78112
//
113+
// Check they don't contain dependencies from the module cache, old prebuilt
114+
// cache, or new prebuilt cache
115+
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=ExportedLib
116+
// RUN: cat %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=SdkLib
117+
//
79118
// RUN: %empty-directory(%t/MCP)
80119
// RUN: echo '4: PASSED'
81120

82121

83122
// 5) Now change the SDK's content and check it no longer uses the prebuilt modules
84123
//
85124
// RUN: echo "// size change" >> %t/my-new-sdk/SdkLib.swiftinterface
86-
// RUN: %target-swift-frontend -typecheck -I %t/my-new-sdk -sdk %t/my-new-sdk -prebuilt-module-cache-path %t/new-prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
125+
// RUN: %target-swift-frontend -typecheck -I %t/my-new-sdk -sdk %t/my-new-sdk -prebuilt-module-cache-path %t/new-dir/prebuilt-cache -module-cache-path %t/MCP -emit-dependencies-path %t/dummy.d -track-system-dependencies %s
87126
//
88127
// Check SDKLib and ExportedLib are in the module cache
89128
// RUN: test -f %t/MCP/SdkLib-*.swiftmodule
90129
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
91130
//
92131
// Check ExportedLib is still a forwarding module and SdkLib is not
93-
// RUN: head -n 1 %t/MCP/ExportedLib-*.swiftmodule | grep -e '---'
94-
// RUN: head -n 1 %t/MCP/SdkLib-*.swiftmodule | not grep -e '---'
132+
// RUN: %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
133+
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
95134
//
96135
// Check ExportedLib still contains the same dependencies
97136
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NEW-EXLIB
137+
// RUN: cat %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=NOCACHE -DLIB_NAME=ExportedLib
138+
//
139+
// Check SdkLib doesn't contain dependencies in the module cache or prebuilt cache
140+
// RUN: llvm-bcanalyzer -dump %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
98141
//
99142
// RUN: %empty-directory(%t/MCP)
100143
//
@@ -106,8 +149,12 @@
106149
// RUN: test -f %t/MCP/ExportedLib-*.swiftmodule
107150
//
108151
// Check neither are forwarding modules
109-
// RUN: head -n 1 %t/MCP/SdkLib-*.swiftmodule | not grep -e '---'
110-
// RUN: head -n 1 %t/MCP/ExportedLib-*.swiftmodule | not grep -e '---'
152+
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/SdkLib-*.swiftmodule
153+
// RUN: not %{python} %S/Inputs/check-is-forwarding-module.py %t/MCP/ExportedLib-*.swiftmodule
154+
//
155+
// Check neither contains dependencies in the module cache or prebuilt cache
156+
// RUN: llvm-bcanalyzer -dump %t/MCP/ExportedLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
157+
// RUN: llvm-bcanalyzer -dump %t/MCP/SdkLib-*.swiftmodule | %FileCheck %s -check-prefix=PREBUILT
111158
//
112159
// RUN: echo '5: PASSED'
113160

0 commit comments

Comments
 (0)