swiftlang / swift-corelibs-xctest

The XCTest Project, A Swift core library for providing unit test support
swift.org
Apache License 2.0
1.15k stars 267 forks source link

Make `XCTMain()` return its exit code instead of calling `exit()`. #468

Closed grynspan closed 1 year ago

grynspan commented 1 year ago

Right now, XCTMain() returns Never and calls exit() to report its status. This makes it difficult (if not outright impossible) to do any post-test cleanup work like writing an event log or other cleanup.

This PR adds a new overload of XCTMain() that instead returns the intended exit code of the process (as CInt, since process exit codes passed to exit() are always of type int in C.) The new overload is, for now, disfavoured until we can teach SwiftPM about it. Once we can (in a subsequent PR), we'll mark the old one disfavored and deprecated.

grynspan commented 1 year ago

@swift-ci please test

grynspan commented 1 year ago

@swift-ci please test

grynspan commented 1 year ago

@swift-ci please test Windows

grynspan commented 1 year ago

Windows build failure is unrelated.

grynspan commented 1 year ago

@swift-ci please test Windows