Skip to content

Commit fe0ffaa

Browse files
committed
Some args cleanup
1 parent 6aee135 commit fe0ffaa

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

Sources/Build/LLBuildCommands.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,27 +249,27 @@ final class TestEntryPointCommand: CustomLLBuildCommand, TestBuildCommand {
249249
@main
250250
@available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings")
251251
struct Runner {
252-
static func which() -> String {
253-
// HACK: abstract this check properly!
254-
let args = CommandLine.arguments
255-
if args.contains("--testing-library=swift-testing") {
256-
return "swift-testing"
257-
} else if args.contains("--testing-library=xctest") {
258-
return "XCTest"
252+
private static func testingLibrary() -> String {
253+
var iterator = CommandLine.arguments.makeIterator()
254+
while let argument = iterator.next() {
255+
if argument == "--testing-library", let libraryName = iterator.next() {
256+
return libraryName.lowercased()
257+
}
259258
}
259+
260260
// Fallback if not specified: run XCTest (legacy behavior)
261-
return "XCTest"
261+
return "xctest"
262262
}
263263
264264
static func main() async {
265-
let which = Self.which()
265+
let testingLibrary = Self.testingLibrary()
266266
#if \#(swiftTestingImportCondition)
267-
if which == "swift-testing" {
267+
if testingLibrary == "swift-testing" {
268268
await Testing.__swiftPMEntryPoint() as Never
269269
}
270270
#endif
271271
#if \#(xctestImportCondition)
272-
if which == "XCTest" {
272+
if testingLibrary == "xctest" {
273273
\#(testObservabilitySetup)
274274
#if os(WASI)
275275
/// On WASI, we can't block the main thread, so XCTestMain is defined as async.

Sources/Commands/SwiftTestCommand.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,6 @@ public struct SwiftTestCommand: AsyncSwiftCommand {
401401
// Pass through all arguments from the command line to Swift Testing.
402402
var additionalArguments = additionalArguments
403403
if library == .swiftTesting {
404-
additionalArguments += ["--"]
405404
additionalArguments += CommandLine.arguments.dropFirst()
406405
}
407406

@@ -678,7 +677,7 @@ extension SwiftTestCommand {
678677
}
679678

680679
if testLibraryOptions.isEnabled(.swiftTesting) {
681-
let additionalArguments = ["--", "--list-tests"] + CommandLine.arguments.dropFirst()
680+
let additionalArguments = ["--list-tests"] + CommandLine.arguments.dropFirst()
682681
let runner = TestRunner(
683682
bundlePaths: testProducts.map(\.bundlePath),
684683
additionalArguments: additionalArguments,
@@ -837,7 +836,7 @@ final class TestRunner {
837836
if library == .swiftTesting {
838837
// HACK: tell the test bundle/executable that we want to run Swift Testing, not XCTest.
839838
// XCTest doesn't understand this argument (yet), so don't pass it there.
840-
args += ["--testing-library=swift-testing"]
839+
args += ["--testing-library", "swift-testing"]
841840
}
842841

843842
return args

0 commit comments

Comments
 (0)