Skip to content

Commit d9ce602

Browse files
authored
Add module aliasing integration tests (#5602)
Resolves rdar://91943961
1 parent 5bd3355 commit d9ce602

File tree

37 files changed

+408
-52
lines changed

37 files changed

+408
-52
lines changed

Fixtures/Miscellaneous/ModuleAliasing/DirectDeps/GamePkg/Package.swift

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

Fixtures/Miscellaneous/ModuleAliasing/DirectDeps/AppPkg/Package.swift renamed to Fixtures/ModuleAliasing/DirectDeps1/AppPkg/Package.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
// swift-tools-version:999.0
1+
// swift-tools-version:5.7
22
import PackageDescription
33

44
let package = Package(
55
name: "AppPkg",
6-
platforms: [
7-
.macOS(.v10_12),
8-
.iOS(.v10),
9-
.tvOS(.v11),
10-
.watchOS(.v5)
11-
],
126
dependencies: [
13-
.package(path: "../GamePkg"),
7+
.package(path: "../UtilsPkg"),
148
],
159
targets: [
1610
.executableTarget(
1711
name: "App",
1812
dependencies: [
1913
"Utils",
20-
.product(name: "UtilsProd",
21-
package: "GamePkg",
14+
.product(name: "Utils",
15+
package: "UtilsPkg",
2216
moduleAliases: ["Utils": "GameUtils"])
2317
],
2418
path: "./Sources/App"),
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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+
],
9+
targets: [
10+
.target(name: "Utils", dependencies: []),
11+
]
12+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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: "Apkg",
8+
products: [
9+
.executable(name: "AApp", targets: ["AApp"]),
10+
.library(name: "Utils", type: .dynamic, targets: ["Utils"]),
11+
],
12+
targets: [
13+
.executableTarget(name: "AApp", dependencies: ["Utils"]),
14+
.target(name: "Utils", dependencies: [])
15+
]
16+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Utils
2+
3+
utilsInA()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public func utilsInA() {
2+
print("Utils in A")
3+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// swift-tools-version:5.7
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "AppPkg",
6+
dependencies: [
7+
.package(path: "../Apkg"),
8+
.package(path: "../Bpkg"),
9+
],
10+
targets: [
11+
.executableTarget(
12+
name: "App",
13+
dependencies: [
14+
.product(name: "Utils",
15+
package: "Apkg",
16+
moduleAliases: ["Utils": "AUtils"]
17+
),
18+
.product(name: "Utils",
19+
package: "Bpkg",
20+
moduleAliases: ["Utils": "BUtils"]
21+
)
22+
]),
23+
]
24+
)
25+
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+
import AUtils
12+
import BUtils
13+
14+
utilsInA()
15+
utilsInB()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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: "Bpkg",
8+
products: [
9+
.library(name: "Utils", targets: ["Utils"]),
10+
],
11+
targets: [
12+
.target(name: "Utils", dependencies: [])
13+
]
14+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public func utilsInB() {
2+
print("Utils in B")
3+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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: "APkg",
8+
products: [
9+
.library(name: "A", targets: ["A"]),
10+
],
11+
dependencies: [
12+
.package(path: "../BPkg"),
13+
.package(path: "../CPkg"),
14+
],
15+
targets: [
16+
.target(name: "A",
17+
dependencies: [
18+
.product(name: "Utils",
19+
package: "BPkg",
20+
moduleAliases: ["Utils": "FooUtils"]
21+
),
22+
.product(name: "Utils",
23+
package: "CPkg",
24+
moduleAliases: ["Utils": "CarUtils"]
25+
),
26+
]),
27+
]
28+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import FooUtils
2+
import CarUtils
3+
4+
public func funcInA() {
5+
print("func in A")
6+
utilsInB()
7+
utilsInC()
8+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// swift-tools-version:5.7
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "AppPkg",
6+
dependencies: [
7+
.package(path: "../APkg"),
8+
.package(path: "../XPkg"),
9+
],
10+
targets: [
11+
.executableTarget(
12+
name: "App",
13+
dependencies: [
14+
.product(name: "A",
15+
package: "APkg",
16+
moduleAliases: ["FooUtils": "AFooUtils"]
17+
),
18+
.product(name: "X",
19+
package: "XPkg",
20+
moduleAliases: ["Utils": "XUtils", "FooUtils": "XFooUtils"]
21+
)
22+
]),
23+
]
24+
)
25+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import A
2+
import X
3+
import AFooUtils
4+
import CarUtils
5+
import XFooUtils
6+
import Utils
7+
8+
funcInA()
9+
funcInX()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// swift-tools-version:5.6
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "BPkg",
6+
products: [
7+
.library(name: "Utils", targets: ["Utils"]),
8+
],
9+
targets: [
10+
.target(name: "Utils", dependencies: [])
11+
]
12+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public func utilsInB() {
2+
print("utils in B")
3+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// swift-tools-version:5.6
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "CPkg",
6+
products: [
7+
.library(name: "Utils", targets: ["Utils"]),
8+
],
9+
targets: [
10+
.target(name: "Utils", dependencies: [])
11+
]
12+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public func utilsInC() {
2+
print("utils in C")
3+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
dependencies: [
12+
.package(path: "../YPkg"),
13+
],
14+
targets: [
15+
.target(name: "X",
16+
dependencies: [
17+
"Utils",
18+
.product(name: "Utils",
19+
package: "YPkg",
20+
moduleAliases: ["Utils": "FooUtils"]
21+
),
22+
]),
23+
.target(name: "Utils", dependencies: [])
24+
]
25+
)
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+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Utils
2+
import FooUtils
3+
4+
public func funcInX() {
5+
print("func in X")
6+
utilsInX()
7+
utilsInY()
8+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// swift-tools-version:5.6
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "YPkg",
6+
products: [
7+
.library(name: "Utils", targets: ["Utils"]),
8+
],
9+
targets: [
10+
.target(name: "Utils", dependencies: [])
11+
]
12+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public func utilsInY() {
2+
print("utils in Y")
3+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// swift-tools-version:5.7
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "Apkg",
6+
products: [
7+
.library(name: "A", targets: ["A"]),
8+
],
9+
dependencies: [
10+
.package(path: "../Bpkg"),
11+
.package(path: "../Cpkg"),
12+
],
13+
targets: [
14+
.target(name: "A",
15+
dependencies: [
16+
.product(name: "Utils",
17+
package: "Bpkg",
18+
moduleAliases: ["Utils": "BUtils"]),
19+
.product(name: "Utils",
20+
package: "Cpkg",
21+
moduleAliases: ["Utils": "CUtils"]),
22+
]
23+
),
24+
]
25+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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 BUtils
12+
import CUtils
13+
14+
public func funcA() {
15+
print("func A")
16+
BUtils.funcB()
17+
CUtils.funcC()
18+
}
19+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// swift-tools-version:5.7
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "AppPkg",
6+
dependencies: [
7+
.package(path: "../Apkg"),
8+
.package(path: "../Xpkg"),
9+
],
10+
targets: [
11+
.executableTarget(
12+
name: "App",
13+
dependencies: [
14+
.product(name: "A",
15+
package: "Apkg"
16+
),
17+
.product(name: "Utils",
18+
package: "Xpkg",
19+
moduleAliases: ["Utils": "XUtils"]
20+
),
21+
]),
22+
]
23+
)
24+
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,10 @@
88
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
99
*/
1010

11+
import A
1112
import Utils
1213

13-
public struct Game: Equatable {
14-
public var levels: [LevelDetector]
14+
print("START")
1515

16-
public static func startGame(for user: String) -> Int {
17-
if user.isEmpty {
18-
return -1
19-
}
20-
return LevelDetector.detect(for: user)
21-
}
22-
}
16+
funcA()
17+
funcX()

0 commit comments

Comments
 (0)