Skip to content

Commit e2f50e4

Browse files
authored
Rename BuildParameters.Testing.Library. (#7806)
1 parent 3f4f2e7 commit e2f50e4

File tree

9 files changed

+49
-30
lines changed

9 files changed

+49
-30
lines changed

Sources/Basics/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ add_library(Basics
7070
Serialization/SerializedJSON.swift
7171
SwiftVersion.swift
7272
SQLiteBackedCache.swift
73+
TestingLibrary.swift
7374
Triple+Basics.swift
7475
Version+Extensions.swift
7576
WritableByteStream+Extensions.swift

Sources/Basics/TestingLibrary.swift

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift open source project
4+
//
5+
// Copyright (c) 2014-2024 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
/// The testing libraries supported by the package manager.
14+
public enum TestingLibrary: Sendable, CustomStringConvertible {
15+
/// The XCTest library.
16+
///
17+
/// This case represents both the open-source swift-corelibs-xctest
18+
/// package and Apple's XCTest framework that ships with Xcode.
19+
case xctest
20+
21+
/// The swift-testing library.
22+
case swiftTesting
23+
24+
public var description: String {
25+
switch self {
26+
case .xctest:
27+
"XCTest"
28+
case .swiftTesting:
29+
"Swift Testing"
30+
}
31+
}
32+
}
33+

Sources/Commands/PackageCommands/Init.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extension SwiftPackageCommand {
5959
// Which testing libraries should be used? XCTest is on by default,
6060
// but Swift Testing must remain off by default until it is present
6161
// in the Swift toolchain.
62-
var supportedTestingLibraries = Set<BuildParameters.Testing.Library>()
62+
var supportedTestingLibraries = Set<TestingLibrary>()
6363
if testLibraryOptions.isEnabled(.xctest) {
6464
supportedTestingLibraries.insert(.xctest)
6565
}

Sources/Commands/SwiftTestCommand.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ public struct SwiftTestCommand: AsyncSwiftCommand {
449449
additionalArguments: [String],
450450
productsBuildParameters: BuildParameters,
451451
swiftCommandState: SwiftCommandState,
452-
library: BuildParameters.Testing.Library
452+
library: TestingLibrary
453453
) async throws -> TestRunner.Result {
454454
// Pass through all arguments from the command line to Swift Testing.
455455
var additionalArguments = additionalArguments
@@ -843,7 +843,7 @@ final class TestRunner {
843843
private let observabilityScope: ObservabilityScope
844844

845845
/// Which testing library to use with this test run.
846-
private let library: BuildParameters.Testing.Library
846+
private let library: TestingLibrary
847847

848848
/// Get the arguments used on this platform to pass test specifiers to XCTest.
849849
static func xctestArguments<S>(forTestSpecifiers testSpecifiers: S) -> [String] where S: Collection, S.Element == String {
@@ -873,7 +873,7 @@ final class TestRunner {
873873
toolchain: UserToolchain,
874874
testEnv: Environment,
875875
observabilityScope: ObservabilityScope,
876-
library: BuildParameters.Testing.Library
876+
library: TestingLibrary
877877
) {
878878
self.bundlePaths = bundlePaths
879879
self.additionalArguments = additionalArguments

Sources/Commands/Utilities/TestingSupport.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ enum TestingSupport {
150150
toolchain: UserToolchain,
151151
destinationBuildParameters buildParameters: BuildParameters,
152152
sanitizers: [Sanitizer],
153-
library: BuildParameters.Testing.Library
153+
library: TestingLibrary
154154
) throws -> Environment {
155155
var env = Environment.current
156156

Sources/CoreCommands/Options.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import ArgumentParser
1414

1515
import var Basics.localFileSystem
1616
import struct Basics.AbsolutePath
17+
import enum Basics.TestingLibrary
1718
import struct Basics.Triple
1819
import func Basics.temp_await
1920

@@ -597,7 +598,7 @@ public struct TestLibraryOptions: ParsableArguments {
597598
help: .private)
598599
public var explicitlyEnableExperimentalSwiftTestingLibrarySupport: Bool?
599600

600-
private func isEnabled(_ library: BuildParameters.Testing.Library, `default`: Bool) -> Bool {
601+
private func isEnabled(_ library: TestingLibrary, `default`: Bool) -> Bool {
601602
switch library {
602603
case .xctest:
603604
explicitlyEnableXCTestSupport ?? `default`
@@ -607,17 +608,17 @@ public struct TestLibraryOptions: ParsableArguments {
607608
}
608609

609610
/// Test whether or not a given library is enabled.
610-
public func isEnabled(_ library: BuildParameters.Testing.Library) -> Bool {
611+
public func isEnabled(_ library: TestingLibrary) -> Bool {
611612
isEnabled(library, default: true)
612613
}
613614

614615
/// Test whether or not a given library was explicitly enabled by the developer.
615-
public func isExplicitlyEnabled(_ library: BuildParameters.Testing.Library) -> Bool {
616+
public func isExplicitlyEnabled(_ library: TestingLibrary) -> Bool {
616617
isEnabled(library, default: false)
617618
}
618619

619620
/// The list of enabled testing libraries.
620-
public var enabledTestingLibraries: [BuildParameters.Testing.Library] {
621+
public var enabledTestingLibraries: [TestingLibrary] {
621622
[.xctest, .swiftTesting].filter(isEnabled)
622623
}
623624
}

Sources/SPMBuildCore/BuildParameters/BuildParameters+Testing.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,6 @@ extension BuildParameters {
8686
/// The style of test product to produce.
8787
public var testProductStyle: TestProductStyle
8888

89-
/// The testing libraries supported by the package manager.
90-
public enum Library: String, Codable, CustomStringConvertible {
91-
/// The XCTest library.
92-
///
93-
/// This case represents both the open-source swift-corelibs-xctest
94-
/// package and Apple's XCTest framework that ships with Xcode.
95-
case xctest = "XCTest"
96-
97-
/// The swift-testing library.
98-
case swiftTesting = "swift-testing"
99-
100-
public var description: String {
101-
rawValue
102-
}
103-
}
104-
10589
public init(
10690
configuration: BuildConfiguration,
10791
targetTriple: Triple,

Sources/Workspace/InitPackage.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public final class InitPackage {
2727
public var packageType: PackageType
2828

2929
/// The set of supported testing libraries to include in the package.
30-
public var supportedTestingLibraries: Set<BuildParameters.Testing.Library>
30+
public var supportedTestingLibraries: Set<TestingLibrary>
3131

3232
/// The list of platforms in the manifest.
3333
///
@@ -36,7 +36,7 @@ public final class InitPackage {
3636

3737
public init(
3838
packageType: PackageType,
39-
supportedTestingLibraries: Set<BuildParameters.Testing.Library> = [.xctest],
39+
supportedTestingLibraries: Set<TestingLibrary> = [.xctest],
4040
platforms: [SupportedPlatform] = []
4141
) {
4242
self.packageType = packageType
@@ -93,7 +93,7 @@ public final class InitPackage {
9393
public convenience init(
9494
name: String,
9595
packageType: PackageType,
96-
supportedTestingLibraries: Set<BuildParameters.Testing.Library>,
96+
supportedTestingLibraries: Set<TestingLibrary>,
9797
destinationPath: AbsolutePath,
9898
installedSwiftPMConfiguration: InstalledSwiftPMConfiguration,
9999
fileSystem: FileSystem
@@ -896,7 +896,7 @@ public final class InitPackage {
896896

897897
private enum InitError: Swift.Error {
898898
case manifestAlreadyExists
899-
case unsupportedTestingLibraryForPackageType(_ testingLibrary: BuildParameters.Testing.Library, _ packageType: InitPackage.PackageType)
899+
case unsupportedTestingLibraryForPackageType(_ testingLibrary: TestingLibrary, _ packageType: InitPackage.PackageType)
900900
}
901901

902902
extension InitError: CustomStringConvertible {

Sources/_InternalTestSupport/misc.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ extension InitPackage {
432432
public convenience init(
433433
name: String,
434434
packageType: PackageType,
435-
supportedTestingLibraries: Set<BuildParameters.Testing.Library> = [.xctest],
435+
supportedTestingLibraries: Set<TestingLibrary> = [.xctest],
436436
destinationPath: AbsolutePath,
437437
fileSystem: FileSystem
438438
) throws {

0 commit comments

Comments
 (0)