Skip to content
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

Fix XCTest entrypoint for WASI by making it async #7400

Merged
merged 1 commit into from Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 8 additions & 7 deletions Sources/Build/BuildOperationBuildSystemDelegateHandler.swift
Expand Up @@ -264,17 +264,18 @@ final class TestEntryPointCommand: CustomLLBuildCommand, TestBuildCommand {
@main
@available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings")
struct Runner {
#if os(WASI)
/// On WASI, we can't block the main thread, so XCTestMain is defined as async.
static func main() async {
\#(testObservabilitySetup)
await XCTMain(__allDiscoveredTests()) as Never
}
#else
static func main() {
\#(testObservabilitySetup)
#if os(WASI)
// FIXME: On WASI, XCTest uses `Task` based waiting not to block the whole process, so
// the `XCTMain` call can return the control and the process will exit by `exit(0)` later.
// This is a workaround until we have WASI threads or swift-testing, which does not block threads.
XCTMain(__allDiscoveredTests())
#else
XCTMain(__allDiscoveredTests()) as Never
#endif
}
#endif
}
"""#
)
Expand Down