Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Sources/Testing/ExitTests/ExitTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,9 @@ extension ExitTest {
_errorInMain(error)
}

// Run some glue code that terminates the process with an exit condition
// that does not match the expected one. If the exit test's body doesn't
// terminate, we'll manually call exit() and cause the test to fail.
let expectingFailure = expectedExitCondition == .failure
exit(expectingFailure ? EXIT_SUCCESS : EXIT_FAILURE)
// If we get to this point without terminating, then we simulate main()'s
// behavior which is to exit with EXIT_SUCCESS.
exit(EXIT_SUCCESS)
}
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/TestingTests/ExitTestTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ private import _TestingInternals
exit(EXIT_FAILURE + 1)
}
}
await #expect(exitsWith: .success) {}
await #expect(exitsWith: .success) {
exit(EXIT_SUCCESS)
}
Expand Down Expand Up @@ -63,7 +64,7 @@ private import _TestingInternals
}

@Test("Exit tests (failing)") func failing() async {
await confirmation("Exit tests failed", expectedCount: 10) { failed in
await confirmation("Exit tests failed", expectedCount: 9) { failed in
var configuration = Configuration()
configuration.eventHandler = { event, _ in
if case .issueRecorded = event.kind {
Expand Down Expand Up @@ -410,7 +411,6 @@ private import _TestingInternals

@Suite(.hidden) struct FailingExitTests {
@Test(.hidden) func failingExitTests() async {
await #expect(exitsWith: .success) {}
await #expect(exitsWith: .failure) {}
await #expect(exitsWith: .exitCode(123)) {}
await #expect(exitsWith: .failure) {
Expand Down