Skip to content

Commit d6db4df

Browse files
committed
Create tests cases to reproduce the module aliasing problem
1 parent 6e3f087 commit d6db4df

File tree

12 files changed

+171
-0
lines changed

12 files changed

+171
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// swift-tools-version:5.7
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "AppPkg",
6+
dependencies: [
7+
.package(path: "../UtilsPkg"),
8+
],
9+
targets: [
10+
.executableTarget(
11+
name: "App",
12+
dependencies: [
13+
"Utils",
14+
.product(name: "Lib",
15+
package: "UtilsPkg",
16+
moduleAliases: [
17+
"Utils": "GameUtils",
18+
"Lib": "GameLib",
19+
]),
20+
],
21+
path: "./Sources/App"),
22+
.target(
23+
name: "Utils",
24+
dependencies: [],
25+
path: "./Sources/Utils"
26+
)
27+
]
28+
)
29+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
*/
10+
11+
import Utils
12+
import GameUtils
13+
import GameLib
14+
15+
Utils.echoModule()
16+
17+
GameLib.userHelp()
18+
19+
let level = LevelDetector.detect(for: "TestUser")
20+
print(level)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
*/
10+
11+
public func echoModule() {
12+
print("Utils")
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// swift-tools-version:5.5
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "UtilsPkg",
6+
products: [
7+
.library(name: "Utils", targets: ["Utils"]),
8+
.library(name: "Lib", targets: ["Lib", "Utils"])
9+
],
10+
targets: [
11+
.target(name: "Utils", dependencies: []),
12+
.target(name: "Lib", dependencies: ["Utils"])
13+
]
14+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Utils
2+
3+
public func userHelp() {
4+
_ = Utils.LevelDetector.detect(for: "someUser")
5+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
*/
10+
11+
public struct LevelDetector: Equatable {
12+
public static func detect(for user: String) -> Int {
13+
return user.count
14+
}
15+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// swift-tools-version:5.7
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "AppPkg",
6+
dependencies: [
7+
.package(path: "../XPkg"),
8+
],
9+
targets: [
10+
.executableTarget(
11+
name: "App",
12+
dependencies: [
13+
.product(name: "X",
14+
package: "XPkg",
15+
moduleAliases: ["Utils": "XUtils", "X": "XNew"]
16+
)
17+
]),
18+
]
19+
)
20+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import XNew
2+
import XUtils
3+
4+
utilsInX()
5+
XNew.funcInX()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// swift-tools-version:5.7
2+
// The swift-tools-version declares the minimum version of Swift required to build this package.
3+
4+
import PackageDescription
5+
6+
let package = Package(
7+
name: "XPkg",
8+
products: [
9+
.library(name: "X", targets: ["X"]),
10+
],
11+
targets: [
12+
.target(name: "X",
13+
dependencies: [
14+
"Utils",
15+
]),
16+
.target(name: "Utils", dependencies: [])
17+
]
18+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public func utilsInX() {
2+
print("utils in X")
3+
}

0 commit comments

Comments
 (0)