Skip to content

Commit 0475efd

Browse files
authored
Merge pull request #32122 from CodaFi/modulality
Add a Test Demonstrating Superfluous Cascading Across Module Boundaries
2 parents 6fa4874 + 71d4c3a commit 0475efd

File tree

9 files changed

+100
-0
lines changed

9 files changed

+100
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
extension Map {
2+
func pin() {}
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"main.swift": {
3+
"object": "./main.o",
4+
"swift-dependencies": "./main.swiftdeps"
5+
},
6+
"usesLib.swift": {
7+
"object": "./usesLib.o",
8+
"swift-dependencies": "./usesLib.swiftdeps"
9+
},
10+
"usesLibTransitively.swift": {
11+
"object": "./usesLib.o",
12+
"swift-dependencies": "./usesLib.swiftdeps"
13+
},
14+
"doesNotUseLib.swift": {
15+
"object": "./doesNotUseLib.o",
16+
"swift-dependencies": "./doesNotUseLib.swiftdeps"
17+
},
18+
"": {
19+
"swift-dependencies": "./main~buildrecord.swiftdeps"
20+
}
21+
}
22+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
public struct Library {
2+
var catalog: [Book]
3+
}
4+
5+
public struct Book {
6+
var title: String
7+
var checkOutCount: Int
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public struct Library {
2+
var catalog: [Book]
3+
}
4+
5+
public struct Book {
6+
var title: String
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"lib.swift": {
3+
"object": "./lib.o",
4+
"swift-dependencies": "./lib.swiftdeps"
5+
},
6+
"": {
7+
"swift-dependencies": "./submodule~buildrecord.swiftdeps"
8+
}
9+
}
10+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Lib
2+
3+
public struct District {
4+
var libraries: [Library]
5+
}
6+
7+
struct Map {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
struct County {
2+
var districts: [District]
3+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// =============================================================================
2+
// Without private dependencies
3+
// =============================================================================
4+
5+
// First, build a submodule
6+
7+
// RUN: %empty-directory(%t)
8+
// RUN: cp %S/Inputs/superfluous-cascade-across-modules/*.swift %t
9+
// RUN: cp %S/Inputs/superfluous-cascade-across-modules/*.json %t
10+
11+
// RUN: %target-build-swift %S/Inputs/superfluous-cascade-across-modules/submodule/lib-before.swift -emit-module -emit-library -module-name Lib -module-link-name Lib -emit-module-path %t/Lib.swiftmodule -o %t/%target-library-name(Lib)
12+
13+
// Build the main executable that depends on the submodule we just built
14+
15+
// RUN: cd %t && %swiftc_driver -emit-module -enable-batch-mode -j2 -incremental -driver-show-incremental -I %t -L %t -lLib -module-name main \
16+
// RUN: -output-file-map ofm.json \
17+
// RUN: main.swift \
18+
// RUN: doesNotUseLib.swift \
19+
// RUN: usesLib.swift \
20+
// RUN: usesLibTransitively.swift >&output1
21+
22+
// Rebuild the submodule
23+
24+
// RUN: %target-build-swift %S/Inputs/superfluous-cascade-across-modules/submodule/lib-after.swift -emit-module -emit-library -module-name Lib -module-link-name Lib -emit-module-path %t/Lib.swiftmodule -o %t/%target-library-name(Lib)
25+
26+
// Rebuild the main executable
27+
28+
// RUN: cd %t && %swiftc_driver -emit-module -enable-batch-mode -j2 -incremental -driver-show-incremental -I %t -L %t -lLib -module-name main \
29+
// RUN: -output-file-map ofm.json \
30+
// RUN: main.swift \
31+
// RUN: doesNotUseLib.swift \
32+
// RUN: usesLib.swift \
33+
// RUN: usesLibTransitively.swift >&output2
34+
35+
// RUN: %FileCheck -check-prefix=CHECK-STATUS-QUO-RECOMPILED %s < %t/output2
36+
37+
// CHECK-STATUS-QUO-RECOMPILED-DAG: Queuing because of external dependencies: {compile: main
38+
// CHECK-STATUS-QUO-RECOMPILED-DAG: Queuing because of external dependencies: {compile: usesLib
39+
// CHECK-STATUS-QUO-RECOMPILED-DAG: Queuing because of external dependencies: {compile: doesNotUseLib

0 commit comments

Comments
 (0)