-
Notifications
You must be signed in to change notification settings - Fork 263
[README] Encourage using the Swift build script #77
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Additional Considerations for Swift on Linux | ||
|
||
When running on the Objective-C runtime, XCTest is able to find all of your tests by simply asking the runtime for the subclasses of `XCTestCase`. It then finds the methods that start with the string `test`. This functionality is not currently present when running on the Swift runtime. Therefore, you must currently provide an additional property, conventionally named `allTests`, in your `XCTestCase` subclass. This method lists all of the tests in the test class. The rest of your test case subclass still contains your test methods. | ||
|
||
```swift | ||
class TestNSURL : XCTestCase { | ||
static var allTests : [(String, TestNSURL -> () throws -> Void)] { | ||
return [ | ||
("test_URLStrings", test_URLStrings), | ||
("test_fileURLWithPath_relativeToURL", test_fileURLWithPath_relativeToURL), | ||
("test_fileURLWithPath", test_fileURLWithPath), | ||
("test_fileURLWithPath_isDirectory", test_fileURLWithPath_isDirectory), | ||
// Other tests go here | ||
] | ||
} | ||
|
||
func test_fileURLWithPath_relativeToURL() { | ||
// Write your test here. Most of the XCTAssert macros you are familiar with are available. | ||
XCTAssertTrue(theBestNumber == 42, "The number is wrong") | ||
} | ||
|
||
// Other tests go here | ||
} | ||
``` | ||
|
||
Also, this version of XCTest does not use the external test runner binary. Instead, create your own executable which links `libXCTest.so`. In your `main.swift`, invoke the `XCTMain` function with an array of the test cases classes that you wish to run, wrapped by the `testCase` helper function. For example: | ||
|
||
```swift | ||
XCTMain([testCase(TestNSString.allTests), testCase(TestNSArray.allTests), testCase(TestNSDictionary.allTests)]) | ||
``` | ||
|
||
The `XCTMain` function does not return, and will cause your test app to exit with either `0` for success or `1` for failure. Command line arguments given to the executable can be used to select a particular test or test case to execute. For example: | ||
|
||
```sh | ||
./FooTests FooTestCase/testFoo # Run a single test method | ||
./FooTests FooTestCase # Run all the tests in FooTestCase | ||
``` | ||
|
||
We are currently investigating ideas on how to make these additional steps for test discovery automatic when running on the Swift runtime. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why you chose to remove the
metavar
values here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think they added any value, and I figured I'd just include them in this pull request.
This is the help text diff:
Personally I think it's less code without them, and removing them provides clearer help text. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation! Looks great.
I'm pretty sure I'd trust your judgement over mine on things Python 😆 Always looking to learn.