Skip to content

Commit 81928c0

Browse files
committed
Restore XML output for Swift Testing when --disable-xctest is passed.
A previous PR, #7796, avoided Swift Testing stomping on XML output from XCTest when both libraries were running tests. However, there's a bug in the implementation where if you pass `--disable-xctest`, we don't end up telling Swift Testing to write any XML at all. This PR fixes that.
1 parent b24cc8b commit 81928c0

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Sources/Commands/SwiftTestCommand.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -469,15 +469,17 @@ public struct SwiftTestCommand: AsyncSwiftCommand {
469469
}
470470
additionalArguments += commandLineArguments
471471

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

0 commit comments

Comments
 (0)