Skip to content

Add module aliasing integration tests #5602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
// swift-tools-version:999.0
// swift-tools-version:5.7
import PackageDescription

let package = Package(
name: "AppPkg",
platforms: [
.macOS(.v10_12),
.iOS(.v10),
.tvOS(.v11),
.watchOS(.v5)
],
dependencies: [
.package(path: "../GamePkg"),
.package(path: "../UtilsPkg"),
],
targets: [
.executableTarget(
name: "App",
dependencies: [
"Utils",
.product(name: "UtilsProd",
package: "GamePkg",
.product(name: "Utils",
package: "UtilsPkg",
moduleAliases: ["Utils": "GameUtils"])
],
path: "./Sources/App"),
Expand Down
12 changes: 12 additions & 0 deletions Fixtures/ModuleAliasing/DirectDeps1/UtilsPkg/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// swift-tools-version:5.5
import PackageDescription

let package = Package(
name: "UtilsPkg",
products: [
.library(name: "Utils", targets: ["Utils"]),
],
targets: [
.target(name: "Utils", dependencies: []),
]
)
16 changes: 16 additions & 0 deletions Fixtures/ModuleAliasing/DirectDeps2/Apkg/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// swift-tools-version:5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Apkg",
products: [
.executable(name: "AApp", targets: ["AApp"]),
.library(name: "Utils", type: .dynamic, targets: ["Utils"]),
],
targets: [
.executableTarget(name: "AApp", dependencies: ["Utils"]),
.target(name: "Utils", dependencies: [])
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Utils

utilsInA()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public func utilsInA() {
print("Utils in A")
}
25 changes: 25 additions & 0 deletions Fixtures/ModuleAliasing/DirectDeps2/AppPkg/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// swift-tools-version:5.7
import PackageDescription

let package = Package(
name: "AppPkg",
dependencies: [
.package(path: "../Apkg"),
.package(path: "../Bpkg"),
],
targets: [
.executableTarget(
name: "App",
dependencies: [
.product(name: "Utils",
package: "Apkg",
moduleAliases: ["Utils": "AUtils"]
),
.product(name: "Utils",
package: "Bpkg",
moduleAliases: ["Utils": "BUtils"]
)
]),
]
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
This source file is part of the Swift.org open source project

Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception

See http://swift.org/LICENSE.txt for license information
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

import AUtils
import BUtils

utilsInA()
utilsInB()
14 changes: 14 additions & 0 deletions Fixtures/ModuleAliasing/DirectDeps2/Bpkg/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// swift-tools-version:5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Bpkg",
products: [
.library(name: "Utils", targets: ["Utils"]),
],
targets: [
.target(name: "Utils", dependencies: [])
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public func utilsInB() {
print("Utils in B")
}
28 changes: 28 additions & 0 deletions Fixtures/ModuleAliasing/NestedDeps1/APkg/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version:5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "APkg",
products: [
.library(name: "A", targets: ["A"]),
],
dependencies: [
.package(path: "../BPkg"),
.package(path: "../CPkg"),
],
targets: [
.target(name: "A",
dependencies: [
.product(name: "Utils",
package: "BPkg",
moduleAliases: ["Utils": "FooUtils"]
),
.product(name: "Utils",
package: "CPkg",
moduleAliases: ["Utils": "CarUtils"]
),
]),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import FooUtils
import CarUtils

public func funcInA() {
print("func in A")
utilsInB()
utilsInC()
}
25 changes: 25 additions & 0 deletions Fixtures/ModuleAliasing/NestedDeps1/AppPkg/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// swift-tools-version:5.7
import PackageDescription

let package = Package(
name: "AppPkg",
dependencies: [
.package(path: "../APkg"),
.package(path: "../XPkg"),
],
targets: [
.executableTarget(
name: "App",
dependencies: [
.product(name: "A",
package: "APkg",
moduleAliases: ["FooUtils": "AFooUtils"]
),
.product(name: "X",
package: "XPkg",
moduleAliases: ["Utils": "XUtils", "FooUtils": "XFooUtils"]
)
]),
]
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import A
import X
import AFooUtils
import CarUtils
import XFooUtils
import Utils

funcInA()
funcInX()
12 changes: 12 additions & 0 deletions Fixtures/ModuleAliasing/NestedDeps1/BPkg/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// swift-tools-version:5.6
import PackageDescription

let package = Package(
name: "BPkg",
products: [
.library(name: "Utils", targets: ["Utils"]),
],
targets: [
.target(name: "Utils", dependencies: [])
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public func utilsInB() {
print("utils in B")
}
12 changes: 12 additions & 0 deletions Fixtures/ModuleAliasing/NestedDeps1/CPkg/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// swift-tools-version:5.6
import PackageDescription

let package = Package(
name: "CPkg",
products: [
.library(name: "Utils", targets: ["Utils"]),
],
targets: [
.target(name: "Utils", dependencies: [])
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public func utilsInC() {
print("utils in C")
}
25 changes: 25 additions & 0 deletions Fixtures/ModuleAliasing/NestedDeps1/XPkg/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// swift-tools-version:5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "XPkg",
products: [
.library(name: "X", targets: ["X"]),
],
dependencies: [
.package(path: "../YPkg"),
],
targets: [
.target(name: "X",
dependencies: [
"Utils",
.product(name: "Utils",
package: "YPkg",
moduleAliases: ["Utils": "FooUtils"]
),
]),
.target(name: "Utils", dependencies: [])
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public func utilsInX() {
print("utils in X")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Utils
import FooUtils

public func funcInX() {
print("func in X")
utilsInX()
utilsInY()
}
12 changes: 12 additions & 0 deletions Fixtures/ModuleAliasing/NestedDeps1/YPkg/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// swift-tools-version:5.6
import PackageDescription

let package = Package(
name: "YPkg",
products: [
.library(name: "Utils", targets: ["Utils"]),
],
targets: [
.target(name: "Utils", dependencies: [])
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public func utilsInY() {
print("utils in Y")
}
25 changes: 25 additions & 0 deletions Fixtures/ModuleAliasing/NestedDeps2/Apkg/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// swift-tools-version:5.7
import PackageDescription

let package = Package(
name: "Apkg",
products: [
.library(name: "A", targets: ["A"]),
],
dependencies: [
.package(path: "../Bpkg"),
.package(path: "../Cpkg"),
],
targets: [
.target(name: "A",
dependencies: [
.product(name: "Utils",
package: "Bpkg",
moduleAliases: ["Utils": "BUtils"]),
.product(name: "Utils",
package: "Cpkg",
moduleAliases: ["Utils": "CUtils"]),
]
),
]
)
19 changes: 19 additions & 0 deletions Fixtures/ModuleAliasing/NestedDeps2/Apkg/Sources/A/File.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
This source file is part of the Swift.org open source project

Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception

See http://swift.org/LICENSE.txt for license information
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

import BUtils
import CUtils

public func funcA() {
print("func A")
BUtils.funcB()
CUtils.funcC()
}

24 changes: 24 additions & 0 deletions Fixtures/ModuleAliasing/NestedDeps2/AppPkg/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// swift-tools-version:5.7
import PackageDescription

let package = Package(
name: "AppPkg",
dependencies: [
.package(path: "../Apkg"),
.package(path: "../Xpkg"),
],
targets: [
.executableTarget(
name: "App",
dependencies: [
.product(name: "A",
package: "Apkg"
),
.product(name: "Utils",
package: "Xpkg",
moduleAliases: ["Utils": "XUtils"]
),
]),
]
)

Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

import A
import Utils

public struct Game: Equatable {
public var levels: [LevelDetector]
print("START")

public static func startGame(for user: String) -> Int {
if user.isEmpty {
return -1
}
return LevelDetector.detect(for: user)
}
}
funcA()
funcX()
Loading