Skip to content
Merged
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
24 changes: 23 additions & 1 deletion Sources/Commands/SwiftTestCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,29 @@ public struct SwiftTestCommand: AsyncSwiftCommand {
// Pass through all arguments from the command line to Swift Testing.
var additionalArguments = additionalArguments
if library == .swiftTesting {
additionalArguments += CommandLine.arguments.dropFirst()
// Reconstruct the arguments list. If an xUnit path was specified, remove it.
var commandLineArguments = [String]()
var originalCommandLineArguments = CommandLine.arguments.dropFirst().makeIterator()
while let arg = originalCommandLineArguments.next() {
if arg == "--xunit-output" {
_ = originalCommandLineArguments.next()
} else {
commandLineArguments.append(arg)
}
}
additionalArguments += commandLineArguments

if var xunitPath = options.xUnitOutput, options.testLibraryOptions.isEnabled(.xctest) {
// We are running Swift Testing, XCTest is also running in this session, and an xUnit path
// was specified. Make sure we don't stomp on XCTest's XML output by having Swift Testing
// write to a different path.
var xunitFileName = "\(xunitPath.basenameWithoutExt)-swift-testing"
if let ext = xunitPath.extension {
xunitFileName = "\(xunitFileName).\(ext)"
}
xunitPath = xunitPath.parentDirectory.appending(xunitFileName)
additionalArguments += ["--xunit-output", xunitPath.pathString]
}
}

let toolchain = try swiftCommandState.getTargetToolchain()
Expand Down