Skip to content

Add swift test --no-parallel #7231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Sources/Commands/SwiftTestTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ struct TestToolOptions: ParsableArguments {

/// If tests should run in parallel mode.
@Flag(name: .customLong("parallel"),
inversion: .prefixedNo,
help: "Run the tests in parallel.")
var shouldRunInParallel: Bool = false

Expand Down Expand Up @@ -553,7 +554,9 @@ public struct SwiftTestTool: SwiftCommand {
// Validation for --num-workers.
if let workers = options.numberOfWorkers {

// The --num-worker option should be called with --parallel.
// The --num-worker option should be called with --parallel. Since
// this option does not affect swift-testing at this time, we can
// effectively ignore that it defaults to enabling parallelization.
guard options.shouldRunInParallel else {
throw StringError("--num-workers must be used with --parallel")
}
Expand Down
8 changes: 8 additions & 0 deletions Tests/CommandsTests/TestToolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ final class TestToolTests: CommandsTestCase {
XCTAssertThrowsCommandExecutionError(try SwiftPM.Test.execute(packagePath: fixturePath)) { error in
// in "swift test" test output goes to stdout
XCTAssertMatch(error.stdout, .contains("Executed 2 tests"))
XCTAssertNoMatch(error.stdout, .contains("[3/3]"))
}

// Try --no-parallel.
XCTAssertThrowsCommandExecutionError(try SwiftPM.Test.execute(["--no-parallel"], packagePath: fixturePath)) { error in
// in "swift test" test output goes to stdout
XCTAssertMatch(error.stdout, .contains("Executed 2 tests"))
XCTAssertNoMatch(error.stdout, .contains("[3/3]"))
}

// Run tests in parallel.
Expand Down