Skip to content

Commit f4f0807

Browse files
committed
Add tests with more chained deps scenarios
1 parent 307c08c commit f4f0807

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/// Test the -module-alias flag with the following scenario:
2+
/// Module 'Utils' imports module 'AppleLogging', and module 'UserN' imports both 'Utils' and 'Logging'.
3+
/// 'Logging' can be aliased 'AppleLogging' via -module-alias.
4+
5+
// RUN: %empty-directory(%t)
6+
7+
/// Create Logging.swiftmodule
8+
// RUN: echo 'public struct Logger { }' > %t/FileLog.swift
9+
// RUN: echo 'public func setup() -> Logging.Logger? { return nil }' >> %t/FileLog.swift
10+
// RUN: %target-swift-frontend -module-name Logging %t/FileLog.swift -emit-module -emit-module-path %t/Logging.swiftmodule
11+
12+
/// Check Logging.swiftmodule is created
13+
// RUN: test -f %t/Logging.swiftmodule
14+
15+
/// Create AppleLogging.swiftmodule
16+
// RUN: echo 'public struct Logger { }' > %t/FileAppleLog.swift
17+
// RUN: echo 'public func setup() -> AppleLogging.Logger? { return nil }' >> %t/FileAppleLog.swift
18+
// RUN: echo 'public func pie() -> AppleLogging.Logger? { return nil }' >> %t/FileAppleLog.swift
19+
// RUN: %target-swift-frontend -module-name AppleLogging %t/FileAppleLog.swift -emit-module -emit-module-path %t/AppleLogging.swiftmodule
20+
21+
/// Check AppleLogging.swiftmodule is created
22+
// RUN: test -f %t/AppleLogging.swiftmodule
23+
24+
/// Create a module Utils that imports AppleLogging
25+
// RUN: echo 'import AppleLogging' > %t/FileUtils.swift
26+
// RUN: echo 'public func start() { _ = AppleLogging.setup() }' >> %t/FileUtils.swift
27+
// RUN: %target-swift-frontend -module-name Utils %t/FileUtils.swift -I %t -emit-module -emit-module-path %t/Utils.swiftmodule -Rmodule-loading 2> %t/result-Utils.output
28+
29+
/// Check Utils.swiftmodule is created and AppleLogging.swiftmodule is loaded
30+
// RUN: test -f %t/Utils.swiftmodule
31+
// RUN: %FileCheck %s -input-file %t/result-Utils.output -check-prefix CHECK-UTILS
32+
// CHECK-UTILS: remark: loaded module at {{.*}}/AppleLogging.swiftmodule
33+
34+
/// Create a module User1 that imports both Utils and Logging, without module aliasing for Logging
35+
// RUN: echo 'import Logging' > %t/File.swift
36+
// RUN: echo 'import Utils' >> %t/File.swift
37+
// RUN: echo 'public func runUtils() { Utils.start() }' >> %t/File.swift
38+
// RUN: echo 'public func runLog() { _ = Logging.setup() }' >> %t/File.swift
39+
// RUN: %target-swift-frontend -module-name User1 %t/File.swift -I %t -emit-module -emit-module-path %t/User1.swiftmodule -Rmodule-loading 2> %t/result-User1.output
40+
41+
/// Check User1.swiftmodule is created and Utils.swiftmodule and Logging.swiftmodule are loaded
42+
// RUN: test -f %t/User1.swiftmodule
43+
// RUN: %FileCheck %s -input-file %t/result-User1.output -check-prefix CHECK-1
44+
// CHECK-1: remark: loaded module at {{.*}}/Logging.swiftmodule
45+
// CHECK-1: remark: loaded module at {{.*}}/Utils.swiftmodule
46+
47+
/// Create a module User2 that imports both Utils and Logging, with module aliasing for Logging
48+
// RUN: echo 'import Logging' > %t/File.swift
49+
// RUN: echo 'import Utils' >> %t/File.swift
50+
// RUN: echo 'public func runUtils() { Utils.start() }' >> %t/File.swift
51+
// RUN: echo 'public func runLog() { _ = Logging.setup() }' >> %t/File.swift
52+
// RUN: %target-swift-frontend -module-name User2 -module-alias Logging=AppleLogging %t/File.swift -I %t -emit-module -emit-module-path %t/User2.swiftmodule -Rmodule-loading 2> %t/result-User2.output
53+
54+
/// Check User2.swiftmodule is created and Utils.swiftmodule and AppleLogging.swiftmodule are loaded but
55+
/// Logging.swiftmodule is not loaded.
56+
// RUN: test -f %t/User2.swiftmodule
57+
// RUN: %FileCheck %s -input-file %t/result-User2.output -check-prefix CHECK-2A
58+
// CHECK-2A: remark: loaded module at {{.*}}/AppleLogging.swiftmodule
59+
// CHECK-2A: remark: loaded module at {{.*}}/Utils.swiftmodule
60+
// RUN: not %FileCheck %s -input-file %t/result-User2.output -check-prefix CHECK-2B
61+
// CHECK-2B: remark: loaded module at {{.*}}/Logging.swiftmodule

0 commit comments

Comments
 (0)