Skip to content

[XCTestMain] Don't XCTPrint arrays of strings #45

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 1 commit into from
Feb 8, 2016

Conversation

modocache
Copy link
Contributor

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:

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. The test suite passes with this change.


On a related note:

  1. Would it be possible to have Apple CI cover this repository as well? I'd love to be able to ask @swift-ci to "please test"!
  2. I'm still trying to find time to add these tests to the Swift validation-test suite. I'd love it if someone beat me to it! 😉

`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.
@briancroom
Copy link
Contributor

Let's get this merged! Thanks for opening this @modocache and bringing up the underrepresentation of this suite in the swift.org automated testing systems (Oh the irony..!)

@mike-ferris-apple do you know who would be in a position to assist with CI integration for this project?

mike-ferris pushed a commit that referenced this pull request Feb 8, 2016
[XCTestMain] Don't XCTPrint arrays of strings
@mike-ferris mike-ferris merged commit cc55ceb into swiftlang:master Feb 8, 2016
@modocache modocache deleted the xctprint-test-failures branch February 8, 2016 15:38
@modocache
Copy link
Contributor Author

Awesome, thanks @mike-ferris-apple! 👍

@ddunbar
Copy link
Contributor

ddunbar commented Feb 8, 2016

Thanks for pushing this along @modocache!

I can help some with CI integration questions -- @emish and @shahmishal are the primary contacts.

@modocache
Copy link
Contributor Author

Excellent, thanks @ddunbar! I'll also need all of your help with #43. If that pull request is merged, it will introduce a dependency between XCTest and Foundation, which affects the Swift build system.

@shahmishal
Copy link
Member

@briancroom, Any specific questions you have about CI?

@shahmishal
Copy link
Member

Would it be possible to have Apple CI cover this repository as well? I'd love to be able to ask @swift-ci to "please test"!

@modocache, This repo has been added to CI for pull request testing, however it can only be triggered by individuals with write access.

https://ci.swift.org/view/Pull%20Request/job/swift-corelibs-xctest-PR-Linux/

@modocache
Copy link
Contributor Author

@shahmishal Awesome! Thanks a ton. Unfortunately the Swift build script doesn't test swift-corelibs-xctest yet, but I'm hoping to fix that soon. #43 (comment) and #43 (comment) have details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants