Skip to content

Commit f2c5311

Browse files
committed
Tests: Migrate PackageCommandTests to Swift Testing and Augment
Migrate the `PackageCommandTests` to Swift Testing and augment the suite to run against the Native and SwiftBuild build system, in addition to the `debug` and `release` build configurations. Relates to: #8997 issue: rdar://157669245
1 parent 6189b0e commit f2c5311

File tree

22 files changed

+6498
-3918
lines changed

22 files changed

+6498
-3918
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.build
2+
.test
23
.index-build
34
DerivedData
45
/.previous-build
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// swift-tools-version: 5.6
2+
import PackageDescription
3+
let package = Package(
4+
name: "MyPackage",
5+
targets: [
6+
.target(
7+
name: "MyLibrary",
8+
plugins: [
9+
"MyPlugin",
10+
]
11+
),
12+
.plugin(
13+
name: "MyPlugin",
14+
capability: .buildTool()
15+
),
16+
]
17+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import PackagePlugin
2+
import Foundation
3+
@main
4+
struct MyBuildToolPlugin: BuildToolPlugin {
5+
func createBuildCommands(
6+
context: PluginContext,
7+
target: Target
8+
) throws -> [Command] {
9+
print("This is text from the plugin")
10+
throw "This is an error from the plugin"
11+
return []
12+
}
13+
14+
}
15+
extension String : Error {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public func Foo() { }
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// swift-tools-version: 5.6
2+
import PackageDescription
3+
let package = Package(
4+
name: "MyPackage",
5+
products: [
6+
.library(
7+
name: "MyLibrary",
8+
targets: ["MyLibrary"]
9+
),
10+
.executable(
11+
name: "MyExecutable",
12+
targets: ["MyExecutable"]
13+
),
14+
],
15+
targets: [
16+
.target(
17+
name: "MyLibrary"
18+
),
19+
.executableTarget(
20+
name: "MyExecutable",
21+
dependencies: ["MyLibrary"]
22+
),
23+
.plugin(
24+
name: "MyBuildToolPlugin",
25+
capability: .buildTool()
26+
),
27+
.plugin(
28+
name: "MyCommandPlugin",
29+
capability: .command(
30+
intent: .custom(verb: "my-build-tester", description: "Help description")
31+
)
32+
),
33+
]
34+
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import PackagePlugin
2+
@main struct MyBuildToolPlugin: BuildToolPlugin {
3+
func createBuildCommands(
4+
context: PluginContext,
5+
target: Target
6+
) throws -> [Command] {
7+
return []
8+
}
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import PackagePlugin
2+
@main struct MyCommandPlugin: CommandPlugin {
3+
func performCommand(
4+
context: PluginContext,
5+
arguments: [String]
6+
) throws {
7+
this is an error
8+
}
9+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import MyLibrary
2+
print("\\(GetGreeting()), World!")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
public func GetGreeting() -> String { return "Hello" }

Sources/PackageModel/Toolchain+SupportedFeatures.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public enum SwiftCompilerFeature {
7070
}
7171

7272
extension Toolchain {
73-
public var supportesSupportedFeatures: Bool {
73+
public var supportsSupportedFeatures: Bool {
7474
guard let features = try? swiftCompilerSupportedFeatures else {
7575
return false
7676
}

0 commit comments

Comments
 (0)