Commit e2ec041
authored
Change default behavior of exit tests to always succeed. (#858)
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:
```swift
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:
- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.1 parent 0b77119 commit e2ec041
File tree
2 files changed
+5
-7
lines changed- Sources/Testing/ExitTests
- Tests/TestingTests
2 files changed
+5
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
166 | 164 | | |
167 | 165 | | |
168 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | | - | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
410 | 411 | | |
411 | 412 | | |
412 | 413 | | |
413 | | - | |
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
| |||
0 commit comments