|
1 | 1 | /// Test the -module-alias flag on the following scenario:
|
2 |
| -/// Module 'Lib' imports module 'Logging', and module 'ClientN' imports both 'Lib' and 'Logging'. |
3 |
| -/// 'Logging' needs to be aliased due to a name collision, so is renamed 'AppleLogging'. |
| 2 | +/// Module 'ClientN' imports 'XLogging' and 'Lib', and 'Lib' imports 'XLogging'. |
| 3 | +/// 'XLogging' needs to be aliased due to a name collision, so is aliased 'AppleLogging'. |
4 | 4 |
|
5 | 5 | // RUN: %empty-directory(%t)
|
| 6 | +// RUN: %{python} %utils/split_file.py -o %t %s |
6 | 7 |
|
7 |
| -/// Input file with a reference to its enclosing module called Logging |
8 |
| -/// Create AppleLogging.swiftmodule by aliasing Logging via -module-alias Logging=AppleLogging |
9 |
| -// RUN: %target-swift-frontend -module-name AppleLogging -module-alias Logging=AppleLogging %S/Inputs/module_aliasing/Logging.swift -emit-module -emit-module-path %t/AppleLogging.swiftmodule |
| 8 | +/// Create AppleLogging.swiftmodule by aliasing XLogging via -module-alias XLogging=AppleLogging |
| 9 | +// RUN: %target-swift-frontend -module-name AppleLogging -module-alias XLogging=AppleLogging %t/FileLogging.swift -emit-module -emit-module-path %t/AppleLogging.swiftmodule |
10 | 10 |
|
11 | 11 | /// Check AppleLogging.swiftmodule is created
|
12 | 12 | // RUN: test -f %t/AppleLogging.swiftmodule
|
13 |
| -// RUN: not test -f %t/Logging.swiftmodule |
| 13 | +// RUN: not test -f %t/XLogging.swiftmodule |
14 | 14 |
|
15 |
| -/// Create a module Lib that imports Logging with -module-alias Logging=AppleLogging |
16 |
| -// RUN: echo 'import Logging' > %t/FileLib.swift |
17 |
| -// RUN: echo 'public func start() { Logging.setup() }' >> %t/FileLib.swift |
18 |
| -// RUN: %target-swift-frontend -module-name Lib %S/Inputs/module_aliasing/Lib.swift -module-alias Logging=AppleLogging -I %t -emit-module -emit-module-path %t/Lib.swiftmodule -Rmodule-loading 2> %t/result-Lib.output |
| 15 | +/// Create a module Lib that imports XLogging WITH -module-alias XLogging=AppleLogging |
| 16 | +// RUN: %target-swift-frontend -module-name Lib %t/FileLib.swift -module-alias XLogging=AppleLogging -I %t -emit-module -emit-module-path %t/Lib.swiftmodule -Rmodule-loading 2> %t/result-Lib.output |
19 | 17 |
|
20 | 18 | /// Check Lib.swiftmodule is created and AppleLogging.swiftmodule is loaded
|
21 | 19 | // RUN: test -f %t/Lib.swiftmodule
|
22 | 20 | // RUN: test -f %t/AppleLogging.swiftmodule
|
23 |
| -// RUN: not test -f %t/Logging.swiftmodule |
| 21 | +// RUN: not test -f %t/XLogging.swiftmodule |
24 | 22 |
|
25 | 23 | // RUN: %FileCheck %s -input-file %t/result-Lib.output -check-prefix CHECK-Lib
|
26 | 24 | // CHECK-Lib: remark: loaded module at {{.*}}AppleLogging.swiftmodule
|
| 25 | +// RUN: not %FileCheck %s -input-file %t/result-Lib.output -check-prefix CHECK-NOT-Lib |
| 26 | +// CHECK-NOT-Lib: remark: loaded module at {{.*}}XLogging.swiftmodule |
27 | 27 |
|
28 |
| -/// Create module Client1 that imports both Lib and Logging, with module aliasing for Logging |
29 |
| -// RUN: %target-swift-frontend -module-name Client1 %S/Inputs/module_aliasing/Client_imports_Lib_and_Logging.swift -module-alias Logging=AppleLogging -I %t -emit-module -emit-module-path %t/Client1.swiftmodule -Rmodule-loading 2>&1 | %FileCheck %s -check-prefix CHECK-1 |
| 28 | +/// Create module Client1 that imports Lib and XLogging, WITH module aliasing for XLogging |
| 29 | +// RUN: %target-swift-frontend -module-name Client1 %t/FileClient.swift -module-alias XLogging=AppleLogging -I %t -emit-module -emit-module-path %t/Client1.swiftmodule -Rmodule-loading -Rmodule-loading 2> %t/result-Client1.output |
30 | 30 |
|
31 | 31 | /// Check Client1.swiftmodule is created and Lib.swiftmodule and AppleLogging.swiftmodule are loaded
|
32 | 32 | // RUN: test -f %t/Client1.swiftmodule
|
33 | 33 | // RUN: test -f %t/Lib.swiftmodule
|
34 | 34 | // RUN: test -f %t/AppleLogging.swiftmodule
|
35 |
| -// RUN: not test -f %t/Logging.swiftmodule |
36 |
| -// CHECK-1: remark: loaded module at {{.*}}AppleLogging.swiftmodule |
37 |
| -// CHECK-1: remark: loaded module at {{.*}}Lib.swiftmodule |
| 35 | +// RUN: not test -f %t/XLogging.swiftmodule |
| 36 | +// RUN: %FileCheck %s -input-file %t/result-Client1.output -check-prefix CHECK-CLIENT1 |
| 37 | +// CHECK-CLIENT1: remark: loaded module at {{.*}}AppleLogging.swiftmodule |
| 38 | +// CHECK-CLIENT1: remark: loaded module at {{.*}}Lib.swiftmodule |
| 39 | +// RUN: not %FileCheck %s -input-file %t/result-Client1.output -check-prefix CHECK-NOT-CLIENT1 |
| 40 | +// CHECK-NOT-CLIENT1: remark: loaded module at {{.*}}XLogging.swiftmodule |
38 | 41 |
|
39 |
| -/// Try creating module Client2 that imports both Lib and Logging, without module aliasing |
40 |
| -// RUN: not %target-swift-frontend -module-name Client2 %S/Inputs/module_aliasing/Client_imports_Lib_and_Logging.swift -I %t -emit-module -emit-module-path %t/Client2.swiftmodule 2> %t/result-Client2.output |
| 42 | +/// Try creating module Client2 that imports Lib and XLogging, WITHOUT module aliasing |
| 43 | +// RUN: not %target-swift-frontend -module-name Client2 %t/FileClient.swift -I %t -emit-module -emit-module-path %t/Client2.swiftmodule 2> %t/result-Client2.output |
41 | 44 |
|
42 | 45 | /// Check that it fails
|
43 |
| -// RUN: %FileCheck %s -input-file %t/result-Client2.output -check-prefix CHECK-2 |
44 |
| -// CHECK-2: {{.*}}error: no such module 'Logging' |
| 46 | +// RUN: %FileCheck %s -input-file %t/result-Client2.output -check-prefix CHECK-CLIENT2 |
| 47 | +// CHECK-CLIENT2: {{.*}}error: no such module 'XLogging' |
45 | 48 |
|
46 |
| -/// Create module Client3 that imports both Lib and AppleLogging, without module aliasing |
47 |
| -// RUN: %target-swift-frontend -module-name Client3 %S/Inputs/module_aliasing/Client_imports_Lib_and_AppleLogging.swift -I %t -emit-module -emit-module-path %t/Client3.swiftmodule -Rmodule-loading 2>&1 | %FileCheck %s -check-prefix CHECK-3 |
| 49 | +/// Create module Client3 that imports Lib and AppleLogging, WITHOUT module aliasing |
| 50 | +// RUN: %target-swift-frontend -module-name Client3 %t/FileClientOther.swift -I %t -emit-module -emit-module-path %t/Client3.swiftmodule -Rmodule-loading 2> %t/result-Client3.output |
48 | 51 |
|
49 | 52 | /// Check Client3.swiftmodule is created and correct modules are loaded
|
50 | 53 | // RUN: test -f %t/Client3.swiftmodule
|
51 | 54 | // RUN: test -f %t/Lib.swiftmodule
|
52 | 55 | // RUN: test -f %t/AppleLogging.swiftmodule
|
53 |
| -// RUN: not test -f %t/Logging.swiftmodule |
54 |
| -// CHECK-3: remark: loaded module at {{.*}}AppleLogging.swiftmodule |
55 |
| -// CHECK-3: remark: loaded module at {{.*}}Lib.swiftmodule |
| 56 | +// RUN: not test -f %t/XLogging.swiftmodule |
| 57 | + |
| 58 | +// RUN: %FileCheck %s -input-file %t/result-Client3.output -check-prefix CHECK-CLIENT3 |
| 59 | +// CHECK-CLIENT3: remark: loaded module at {{.*}}AppleLogging.swiftmodule |
| 60 | +// CHECK-CLIENT3: remark: loaded module at {{.*}}Lib.swiftmodule |
| 61 | +// RUN: not %FileCheck %s -input-file %t/result-Client3.output -check-prefix CHECK-NOT-CLIENT3 |
| 62 | +// CHECK-NOT-CLIENT3: remark: loaded module at {{.*}}XLogging.swiftmodule |
| 63 | + |
| 64 | +// BEGIN FileLogging.swift |
| 65 | +public struct Logger { |
| 66 | + public init() {} |
| 67 | +} |
| 68 | +public func setup() -> XLogging.Logger? { |
| 69 | + return Logger() |
| 70 | +} |
| 71 | + |
| 72 | +// BEGIN FileLib.swift |
| 73 | +import XLogging |
| 74 | + |
| 75 | +public func start() { |
| 76 | + _ = XLogging.setup() |
| 77 | +} |
| 78 | + |
| 79 | +// BEGIN FileClient.swift |
| 80 | +import XLogging |
| 81 | +import Lib |
| 82 | +public func rubLib() { |
| 83 | + Lib.start() |
| 84 | +} |
| 85 | +public func runLog() { |
| 86 | + _ = XLogging.setup() |
| 87 | +} |
| 88 | + |
| 89 | + |
| 90 | +// BEGIN FileClientOther.swift |
| 91 | +import AppleLogging |
| 92 | +import Lib |
| 93 | +public func rubLib() { |
| 94 | + Lib.start() |
| 95 | +} |
| 96 | +public func runLog() { |
| 97 | + _ = AppleLogging.setup() |
| 98 | +} |
| 99 | + |
0 commit comments