From 75358f368ae63241490a15140ea1bc2712b58cda Mon Sep 17 00:00:00 2001 From: Jonathan Grynspan Date: Wed, 17 Jul 2024 17:48:35 -0400 Subject: [PATCH] Revert "Remove `--enable-swift-testing` _et al._ from `swift build`. (#7784)" This reverts commit 7d0230b793c9092468a4ef0c970fbfce0eda7049. --- Sources/Commands/SwiftBuildCommand.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Sources/Commands/SwiftBuildCommand.swift b/Sources/Commands/SwiftBuildCommand.swift index dbbeadec15b..f071a9e599e 100644 --- a/Sources/Commands/SwiftBuildCommand.swift +++ b/Sources/Commands/SwiftBuildCommand.swift @@ -104,6 +104,21 @@ struct BuildCommandOptions: ParsableArguments { /// If should link the Swift stdlib statically. @Flag(name: .customLong("static-swift-stdlib"), inversion: .prefixedNo, help: "Link Swift stdlib statically") public var shouldLinkStaticSwiftStdlib: Bool = false + + /// Which testing libraries to use (and any related options.) + @OptionGroup() + var testLibraryOptions: TestLibraryOptions + + func validate() throws { + // If --build-tests was not specified, it does not make sense to enable + // or disable either testing library. + if !buildTests { + if testLibraryOptions.explicitlyEnableXCTestSupport != nil + || testLibraryOptions.explicitlyEnableSwiftTestingLibrarySupport != nil { + throw StringError("pass --build-tests to build test targets") + } + } + } } /// swift-build command namespace