Skip to content

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Dec 13, 2024

Exit tests simulate calling main() (or some similar thing), but if you don't explicitly exit from them, they force a failure. After much mulling and some discussion with colleagues a while back, we should change the behavior so that, if a test doesn't otherwise terminate, it acts as if main() returned naturally—that is, by exiting with EXIT_SUCCESS rather than by forcing EXIT_FAILURE. This behavior is more consistent with the feature's theory of operation.

For example:

await #expect(exitsWith: .success) {
  assert(2 > 1) // this is true and doesn't assert, so this test should pass, right?
}

Exit tests remain an experimental feature.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

Exit tests simulate calling `main()` (or some similar thing), but if you don't explicitly
exit from them, they force a failure. After much mulling and some discussion with
colleagues a while back, we should change the behavior so that, if a test doesn't
otherwise terminate, it acts as if `main()` returned naturally—that is, by exiting with
`EXIT_SUCCESS` rather than by forcing `EXIT_FAILURE`. This behavior is more consistent
with the feature's theory of operation.
@grynspan grynspan added bug 🪲 Something isn't working exit-tests ☠️ Work related to exit tests labels Dec 13, 2024
@grynspan grynspan self-assigned this Dec 13, 2024
@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan grynspan merged commit e2ec041 into main Dec 13, 2024
3 checks passed
@grynspan grynspan deleted the jgrynspan/exit-test-success-by-default branch December 13, 2024 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working exit-tests ☠️ Work related to exit tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants