Skip to content

Commit 19ba3d1

Browse files
grynspanbnbarham
authored andcommitted
Disable Swift Testing by default in swift package init.
This PR turns Swift Testing back off by default when running `swift package init` because it's not available in the toolchain yet and the package dependency may come as a surprise (also, it breaks CI, but who's counting?) Follow-up to #7766.
1 parent 41405ac commit 19ba3d1

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Sources/Commands/PackageCommands/Init.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,22 @@ extension SwiftPackageCommand {
5555
}
5656

5757
let packageName = self.packageName ?? cwd.basename
58+
59+
// Which testing libraries should be used? XCTest is on by default,
60+
// but Swift Testing must remain off by default until it is present
61+
// in the Swift toolchain.
62+
var supportedTestingLibraries = Set<BuildParameters.Testing.Library>()
63+
if testLibraryOptions.isEnabled(.xctest) {
64+
supportedTestingLibraries.insert(.xctest)
65+
}
66+
if testLibraryOptions.explicitlyEnableSwiftTestingLibrarySupport == true || testLibraryOptions.explicitlyEnableExperimentalSwiftTestingLibrarySupport == true {
67+
supportedTestingLibraries.insert(.swiftTesting)
68+
}
69+
5870
let initPackage = try InitPackage(
5971
name: packageName,
6072
packageType: initMode,
61-
supportedTestingLibraries: Set(testLibraryOptions.enabledTestingLibraries),
73+
supportedTestingLibraries: supportedTestingLibraries,
6274
destinationPath: cwd,
6375
installedSwiftPMConfiguration: swiftCommandState.getHostToolchain().installedSwiftPMConfiguration,
6476
fileSystem: swiftCommandState.fileSystem

0 commit comments

Comments
 (0)