-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[tests] Use XCTMain() for Linux tests #66
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
Conversation
// Linux, where it is already defined by swift-corelibs-xctest. | ||
#if os(OSX) | ||
public protocol XCTestCaseProvider { | ||
var allTests : [(String, () -> ())] { get } |
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.
This should be updated to () -> Void
, as per swiftlang/swift-corelibs-xctest#13.
Good idea! Building on that idea: we could conditionally define |
Could do, although I have no idea how that would ever happen. Test bundles never run their main code. |
`XCTMain()` is the canonical entry point for XCTest on Linux. The continued development of swift-corelibs-xctest would be made simpler if each consumer used this entry point to run their unit tests. - Split XCTestCaseProvider out into its own package, which the tests depend upon. Each test makes explicit reference to XCTestCaseProvider, which means it must be defined on both (1) Linux and (2) OS X, and it must be defined on OS X whether running the tests via (2a) `Utilities/bootstrap` or via (2b) the Xcode project. Test dependencies defined in `Utilities/bootstrap` take care of 1, 2, and 2a. - Add an XCTestCaseProvider target to the Xcode project, which takes care of item 2b from the bullet point above. - Also define XCTMain() on OS X in XCTestCaseProvider. This is because `Utilities/bootstrap` compiles test packages' main.swift files, regardless of whether they are ever executed. These files refer to `XCTMain()` (so we need to define it), but it is never run (so its implementation raises a fatal error).
fe393b8
to
28f7305
Compare
var allTests : [(String, () -> ())] { get } | ||
} | ||
|
||
public func XCTMain(testCases: [XCTestCaseProvider]) { |
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.
Updated the pull request such that XCTMain
is also conditionally defined. Because we don't depend on XCTest
for this shim framework, the function takes an array of XCTestCaseProvider
, as opposed to the array of XCTestCase
the swift-corelibs-xctest XCTMain
function takes.
This wouldn't have worked unless #70 was merged--thanks!!
Thanks! |
[tests] Use XCTMain() for Linux tests
…warning Disable analyzer for `raw_ostream.cpp`
XCTMain()
is the canonical entry point for XCTest on Linux.The continued development of swift-corelibs-xctest would be made
simpler if each consumer used this entry point to run their unit tests.
Modify
Utilities/bootstrap
so that it would not includemain.swift
files in test targets when compiling on OS X. Thesefiles are only necessary on platforms that do not use Objective-C's
XCTest; they should not be included in Linux builds.
depend upon. Each test makes explicit reference to XCTestCaseProvider,
which means it must be defined on both (1) Linux and (2) OS X, and it must be
defined on OS X whether running the tests via (2a)
Utilities/bootstrap
orvia (2b) the Xcode project. Test dependencies defined in
Utilities/bootstrap
take care of 1, 2, and 2a.care of item 2b from the bullet point above.
(Note that the following isn't included in any commit message in this pull request.)
Another attempt at #28. Read the discussion there for additional context.