Skip to content

Commit 1d0c84c

Browse files
committed
Update tests
1 parent adf33e0 commit 1d0c84c

13 files changed

+270
-173
lines changed

test/Frontend/Inputs/module_aliasing/Client.swift

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/Frontend/Inputs/module_aliasing/Client_imports_Lib_and_AppleLogging.swift

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/Frontend/Inputs/module_aliasing/Client_imports_Lib_and_Logging.swift

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/Frontend/Inputs/module_aliasing/Lib.swift

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/Frontend/Inputs/module_aliasing/Logging.swift

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/Frontend/module-alias-explicit-build.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,3 @@
4444

4545
// RUN: %FileCheck %s -input-file %t/outputs/load-result.output -check-prefix CHECK
4646
// CHECK: remark: loaded module at {{.*}}Bar.swiftmodule
47-
Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,69 @@
11
/// Test the -module-alias flag with the following scenario:
2-
/// Module 'Lib' imports module 'LoggingApple', and module 'ClientN' imports both 'Lib' and 'Logging'.
3-
/// 'Logging' can be aliased 'LoggingApple' via -module-alias.
2+
/// Module 'ClientN' imports 'XLogging' and 'Lib', and 'Lib' imports module 'AppleLogging'.
3+
/// 'XLogging' can be aliased 'AppleLogging' via -module-alias.
44

55
// RUN: %empty-directory(%t)
6+
// RUN: %{python} %utils/split_file.py -o %t %s
67

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
8+
/// Create XLogging.swiftmodule
9+
// RUN: %target-swift-frontend -module-name XLogging %t/FileLogging.swift -emit-module -emit-module-path %t/XLogging.swiftmodule
10+
// RUN: test -f %t/XLogging.swiftmodule
1111

12-
/// Check Logging.swiftmodule is created
13-
// RUN: test -f %t/Logging.swiftmodule
12+
/// Create AppleLogging.swiftmodule
13+
// RUN: %target-swift-frontend -module-name AppleLogging %t/FileLogging.swift -emit-module -emit-module-path %t/AppleLogging.swiftmodule
14+
// RUN: test -f %t/AppleLogging.swiftmodule
1415

15-
/// Create LoggingApple.swiftmodule
16-
// RUN: echo 'public struct Logger { }' > %t/FileAppleLog.swift
17-
// RUN: echo 'public func setup() -> LoggingApple.Logger? { return nil }' >> %t/FileAppleLog.swift
18-
// RUN: echo 'public func pie() -> LoggingApple.Logger? { return nil }' >> %t/FileAppleLog.swift
19-
// RUN: %target-swift-frontend -module-name LoggingApple %t/FileAppleLog.swift -emit-module -emit-module-path %t/LoggingApple.swiftmodule
20-
21-
/// Check LoggingApple.swiftmodule is created
22-
// RUN: test -f %t/LoggingApple.swiftmodule
23-
24-
/// Create a module Lib that imports LoggingApple
25-
// RUN: echo 'import LoggingApple' > %t/FileLib.swift
26-
// RUN: echo 'public func start() { _ = LoggingApple.setup() }' >> %t/FileLib.swift
16+
/// Create module Lib that imports AppleLogging
2717
// RUN: %target-swift-frontend -module-name Lib %t/FileLib.swift -I %t -emit-module -emit-module-path %t/Lib.swiftmodule -Rmodule-loading 2> %t/result-Lib.output
2818

29-
/// Check Lib.swiftmodule is created and LoggingApple.swiftmodule is loaded
19+
/// Check Lib.swiftmodule is created and AppleLogging.swiftmodule is loaded
3020
// RUN: test -f %t/Lib.swiftmodule
3121
// RUN: %FileCheck %s -input-file %t/result-Lib.output -check-prefix CHECK-Lib
32-
// CHECK-Lib: remark: loaded module at {{.*}}LoggingApple.swiftmodule
22+
// CHECK-Lib: remark: loaded module at {{.*}}AppleLogging.swiftmodule
3323

34-
/// Create a module Client1 that imports both Lib and Logging, without module aliasing for Logging
35-
// RUN: echo 'import Logging' > %t/File.swift
36-
// RUN: echo 'import Lib' >> %t/File.swift
37-
// RUN: echo 'public func runLib() { Lib.start() }' >> %t/File.swift
38-
// RUN: echo 'public func runLog() { _ = Logging.setup() }' >> %t/File.swift
39-
// RUN: %target-swift-frontend -module-name Client1 %t/File.swift -I %t -emit-module -emit-module-path %t/Client1.swiftmodule -Rmodule-loading 2> %t/result-Client1.output
24+
/// Create module Client1 that imports Lib and XLogging, WITHOUT module aliasing for XLogging
25+
// RUN: %target-swift-frontend -module-name Client1 %t/FileClient.swift -I %t -emit-module -emit-module-path %t/Client1.swiftmodule -Rmodule-loading 2> %t/result-Client1.output
4026

41-
/// Check Client1.swiftmodule is created and Lib.swiftmodule and Logging.swiftmodule are loaded
27+
/// Check Client1.swiftmodule is created and Lib.swiftmodule and XLogging.swiftmodule are loaded
4228
// RUN: test -f %t/Client1.swiftmodule
4329
// RUN: %FileCheck %s -input-file %t/result-Client1.output -check-prefix CHECK-1
44-
// CHECK-1: remark: loaded module at {{.*}}Logging.swiftmodule
30+
// CHECK-1: remark: loaded module at {{.*}}XLogging.swiftmodule
4531
// CHECK-1: remark: loaded module at {{.*}}Lib.swiftmodule
4632

47-
/// Create a module Client2 that imports both Lib and Logging, with module aliasing for Logging
48-
// RUN: echo 'import Logging' > %t/File.swift
49-
// RUN: echo 'import Lib' >> %t/File.swift
50-
// RUN: echo 'public func runLib() { Lib.start() }' >> %t/File.swift
51-
// RUN: echo 'public func runLog() { _ = Logging.setup() }' >> %t/File.swift
52-
// RUN: %target-swift-frontend -module-name Client2 -module-alias Logging=LoggingApple %t/File.swift -I %t -emit-module -emit-module-path %t/Client2.swiftmodule -Rmodule-loading 2> %t/result-Client2.output
33+
/// Create a module Client2 that imports Lib and XLogging, WITH module aliasing for XLogging
34+
// RUN: %target-swift-frontend -module-name Client2 -module-alias XLogging=AppleLogging %t/FileClient.swift -I %t -emit-module -emit-module-path %t/Client2.swiftmodule -Rmodule-loading 2> %t/result-Client2.output
5335

54-
/// Check Client2.swiftmodule is created and Lib.swiftmodule and LoggingApple.swiftmodule are loaded but
55-
/// Logging.swiftmodule is not loaded.
36+
/// Check Client2.swiftmodule is created and Lib.swiftmodule and AppleLogging.swiftmodule are
37+
/// loaded but XLogging.swiftmodule is not loaded.
5638
// RUN: test -f %t/Client2.swiftmodule
5739
// RUN: %FileCheck %s -input-file %t/result-Client2.output -check-prefix CHECK-2A
58-
// CHECK-2A: remark: loaded module at {{.*}}LoggingApple.swiftmodule
40+
// CHECK-2A: remark: loaded module at {{.*}}AppleLogging.swiftmodule
5941
// CHECK-2A: remark: loaded module at {{.*}}Lib.swiftmodule
6042
// RUN: not %FileCheck %s -input-file %t/result-Client2.output -check-prefix CHECK-2B
61-
// CHECK-2B: remark: loaded module at {{.*}}Logging.swiftmodule
43+
// CHECK-2B: remark: loaded module at {{.*}}XLogging.swiftmodule
44+
45+
46+
// BEGIN FileLogging.swift
47+
public struct Logger {
48+
public init() {}
49+
}
50+
public func setup() -> XLogging.Logger? {
51+
return Logger()
52+
}
53+
54+
// BEGIN FileLib.swift
55+
import AppleLogging
56+
57+
public func start() {
58+
_ = AppleLogging.setup()
59+
}
60+
61+
// BEGIN FileClient.swift
62+
import XLogging
63+
import Lib
64+
public func rubLib() {
65+
Lib.start()
66+
}
67+
public func runLog() {
68+
_ = XLogging.setup()
69+
}
Lines changed: 69 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,99 @@
11
/// 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'.
44

55
// RUN: %empty-directory(%t)
6+
// RUN: %{python} %utils/split_file.py -o %t %s
67

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
1010

1111
/// Check AppleLogging.swiftmodule is created
1212
// RUN: test -f %t/AppleLogging.swiftmodule
13-
// RUN: not test -f %t/Logging.swiftmodule
13+
// RUN: not test -f %t/XLogging.swiftmodule
1414

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
1917

2018
/// Check Lib.swiftmodule is created and AppleLogging.swiftmodule is loaded
2119
// RUN: test -f %t/Lib.swiftmodule
2220
// RUN: test -f %t/AppleLogging.swiftmodule
23-
// RUN: not test -f %t/Logging.swiftmodule
21+
// RUN: not test -f %t/XLogging.swiftmodule
2422

2523
// RUN: %FileCheck %s -input-file %t/result-Lib.output -check-prefix CHECK-Lib
2624
// 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
2727

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
3030

3131
/// Check Client1.swiftmodule is created and Lib.swiftmodule and AppleLogging.swiftmodule are loaded
3232
// RUN: test -f %t/Client1.swiftmodule
3333
// RUN: test -f %t/Lib.swiftmodule
3434
// 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
3841

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
4144

4245
/// 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'
4548

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
4851

4952
/// Check Client3.swiftmodule is created and correct modules are loaded
5053
// RUN: test -f %t/Client3.swiftmodule
5154
// RUN: test -f %t/Lib.swiftmodule
5255
// 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+

test/Frontend/module-alias-interface.swift

Lines changed: 0 additions & 27 deletions
This file was deleted.

test/Frontend/module-alias-load.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
/// Test the -module-alias flag.
22

33
// RUN: %empty-directory(%t)
4+
// RUN: %{python} %utils/split_file.py -o %t %s
45

56
/// Create a module Bar
6-
// RUN: echo 'public func bar() {}' > %t/FileBar.swift
77
// RUN: %target-swift-frontend -module-name Bar %t/FileBar.swift -emit-module -emit-module-path %t/Bar.swiftmodule
88

99
/// Check Bar.swiftmodule is created
1010
// RUN: test -f %t/Bar.swiftmodule
1111

1212
/// Create a module Foo that imports Cat with -module-alias Cat=Bar with a serialized modue loader
13-
// RUN: echo 'import Cat' > %t/FileFoo.swift
1413
// RUN: %target-swift-frontend -module-name Foo %t/FileFoo.swift -module-alias Cat=Bar -I %t -emit-module -emit-module-path %t/Foo.swiftmodule -Rmodule-loading 2> %t/load-result-foo.output
1514

1615
/// Check Foo.swiftmodule is created and Bar.swiftmodule is loaded
@@ -32,3 +31,8 @@
3231
// CHECK-ZOO: remark: loaded module at {{.*}}Bar.swiftmodule
3332

3433

34+
// BEGIN FileBar.swift
35+
public func bar() {}
36+
37+
// BEGIN FileFoo.swift
38+
import Cat
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/// Test a serialized interface contains the module real names when -module-alias flag is passed.
2+
///
3+
/// 'Lib' imports module 'XLogging', and 'XLogging' is aliased 'AppleLogging'.
4+
5+
// RUN: %empty-directory(%t)
6+
// RUN: %{python} %utils/split_file.py -o %t %s
7+
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 -enable-library-evolution
10+
11+
/// Check AppleLogging.swiftmodule is created
12+
// RUN: test -f %t/AppleLogging.swiftmodule
13+
// RUN: not test -f %t/XLogging.swiftmodule
14+
15+
/// Check AppleLogging.swiftmodule correctly contains AppleLogging as module name in the binary
16+
// RUN: llvm-bcanalyzer --dump %t/AppleLogging.swiftmodule | %FileCheck %s -check-prefix=BCANALYZER-FOUND
17+
// BCANALYZER-FOUND: MODULE_NAME{{.*}}AppleLogging
18+
19+
// RUN: not llvm-bcanalyzer --dump %t/AppleLogging.swiftmodule | %FileCheck %s -check-prefix=BCANALYZER-NOT-FOUND
20+
// BCANALYZER-NOT-FOUND: MODULE_NAME{{.*}}XLogging
21+
22+
/// Create an interface for Lib that imports XLogging with -module-alias XLogging=AppleLogging
23+
// RUN: %target-swift-frontend -module-name Lib %t/FileLib.swift -module-alias XLogging=AppleLogging -I %t -emit-module -emit-module-path %t/Lib.swiftmodule -swift-version 5 -enable-library-evolution -I %t -Rmodule-loading 2> %t/result-Lib.output
24+
25+
/// Check Lib.swiftinterface is created
26+
// RUN: test -f %t/Lib.swiftinterface
27+
// RUN: test -f %t/AppleLogging.swiftmodule
28+
// RUN: not test -f %t/XLogging.swiftmodule
29+
30+
/// Check AppleLogging.swiftmodule is loaded
31+
// RUN: %FileCheck %s -input-file %t/result-Lib.output -check-prefix CHECK-LOAD
32+
// CHECK-LOAD: remark: loaded module at {{.*}}AppleLogging.swiftmodule
33+
34+
/// Check XLogging.swiftmodule is not loaded
35+
// RUN: not %FileCheck %s -input-file %t/result-Lib.output -check-prefix CHECK-NOT-LOAD
36+
// CHECK-NOT-LOAD: remark: loaded module at {{.*}}XLogging.swiftmodule
37+
38+
/// Check imported modules contain AppleLogging, not XLogging
39+
// RUN: %FileCheck %s -input-file %t/Lib.swiftinterface -check-prefix CHECK-IMPORT
40+
// CHECK-IMPORT: -module-alias XLogging=AppleLogging
41+
// CHECK-IMPORT: import AppleLogging
42+
43+
// RUN: not %FileCheck %s -input-file %t/Lib.swiftinterface -check-prefix CHECK-NOT-IMPORT
44+
// CHECK-NOT-IMPORT: import XLogging
45+
46+
47+
// BEGIN FileLogging.swift
48+
public struct Logger {
49+
public init() {}
50+
}
51+
public func setup() -> XLogging.Logger? {
52+
return Logger()
53+
}
54+
55+
// BEGIN FileLib.swift
56+
import XLogging
57+
58+
public func start() {
59+
_ = XLogging.setup()
60+
}

0 commit comments

Comments
 (0)