Skip to content

Commit e6f3120

Browse files
committed
[XCTestMain] Don't XCTPrint arrays of strings
`XCTPrint()` takes a variadic argument of items to print, mirroring the API of `print()` itself. Unfortunately, passing this variadic argument directly to `print()` causes an array object to be printed. For example: ```swift func XCTPrint(items: Any...) { print(items) } XCTPrint("Hello!") // Prints '["Hello!"]\n' ``` As a result of this behavior, swift-corelibs-xctest currently prints out test output such as the following: ``` ["Test Case \'ErrorHandling.test_shouldButDoesNotThrowErrorInAssertion\' failed (0.0 seconds)."] ["Test Case \'ErrorHandling.test_shouldThrowErrorInAssertion\' started."] ``` This is different from the expected output in `Tests/Functional`, which is causing the test suite to fail. Instead of mirroring the `print()` API, have `XCTPrint()` simply take a string object to print. This has the added benefit of being simpler--we can add the variadic arguments and the line separator parameter back if we ever need them.
1 parent a764529 commit e6f3120

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/XCTest/XCTestMain.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import Glibc
1818
import Darwin
1919
#endif
2020

21-
internal func XCTPrint(items: Any..., separator: String = " ", terminator: String = "\n") {
22-
print(items, separator: separator, terminator: terminator)
21+
internal func XCTPrint(message: String) {
22+
print(message)
2323
fflush(stdout)
2424
}
2525

0 commit comments

Comments
 (0)