Skip to content

Commit 8843cb6

Browse files
author
Harlan Haskins
committed
[test] Make sure we don't double-compile parseable dependencies
Adds a test to make sure that there's only one version of a dependent module, regardless how many -swift-versions are present in the dependency hierarchy.
1 parent 6ae20a9 commit 8843cb6

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %empty-directory(%t)
2+
//
3+
// Test will build a module TestModule that depends on OtherModule and LeafModule (built from other.swift and leaf.swift).
4+
//
5+
// RUN: echo 'public func LeafFunc() -> Int { return 10; }' >%t/leaf.swift
6+
//
7+
// RUN: echo 'import LeafModule' >%t/other.swift
8+
// RUN: echo 'public func OtherFunc() -> Int { return LeafFunc(); }' >>%t/other.swift
9+
//
10+
// Phase 1: build LeafModule into a .swiftinterface file with -swift-version 4:
11+
//
12+
// RUN: %target-swift-frontend -swift-version 4 -I %t -module-cache-path %t/modulecache -emit-parseable-module-interface-path %t/LeafModule.swiftinterface -module-name LeafModule %t/leaf.swift -typecheck
13+
//
14+
// Phase 2: build OtherModule into a .swiftinterface file with -swift-version 4.2:
15+
//
16+
// RUN: %target-swift-frontend -swift-version 4.2 -I %t -module-cache-path %t/modulecache -emit-parseable-module-interface-path %t/OtherModule.swiftinterface -module-name OtherModule %t/other.swift -enable-parseable-module-interface -typecheck
17+
//
18+
// Phase 3: build TestModule in -swift-version 5 and import both of these:
19+
//
20+
// RUN: %target-swift-frontend -swift-version 5 -I %t -module-cache-path %t/modulecache -module-name TestModule %s -enable-parseable-module-interface -typecheck
21+
//
22+
// Phase 4: make sure we only compiled LeafModule and OtherModule one time:
23+
//
24+
// RUN: NUM_LEAF_MODULES=$(find %t/modulecache -type f -name 'LeafModule-*.swiftmodule' | wc -l)
25+
// RUN: NUM_OTHER_MODULES=$(find %t/modulecache -type f -name 'OtherModule-*.swiftmodule' | wc -l)
26+
// RUN: if [ ! $NUM_LEAF_MODULES -eq 1 ]; then echo "Should only be 1 LeafModule, found $NUM_LEAF_MODULES"; exit 1; fi
27+
// RUN: if [ ! $NUM_OTHER_MODULES -eq 1 ]; then echo "Should only be 1 OtherModule, found $NUM_OTHER_MODULES"; exit 1; fi
28+
import LeafModule
29+
import OtherModule

0 commit comments

Comments
 (0)