You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR introduces a "back channel" file handle to exit tests, allowing us to
record issues that occur within exit test bodies. For example:
```swift
await #expect(exitsWith: .failure) {
let context = try #require(possiblyMissingContext)
...
}
```
In this example, if the call to `try #require()` finds `nil`, it will record an
issue, but that issue today will be lost because there's no mechanism to forward
the issue back to the parent process hosting the exit test. This PR fixes that!
Issues are converted to JSON using the same schema we use for event handling,
then written over a pipe back to the parent process where they are decoded. This
decoding is lossy, so there will be further refinement needed here to try to
preserve more information about the recorded issues. That said, "it's got good
bones" right?
On Darwin, Linux, and FreeBSD, the pipe's write end is allowed to survive into
the child process (i.e. no `FD_CLOEXEC`). On Windows, the equivalent is to tell
`CreateProcessW()` to explicitly inherit a `HANDLE`. The identity of this file
descriptor or handle is passed to the child process via environment variable.
The child process then parses the file descriptor or handle out of the
environment and converts it back to a `FileHandle` that is then connected to an
instance of `Configuration` with an event handler set, and off we go.
Because we can now report these issues back to the parent process, I've removed
the compile-time diagnostic in the `#expect(exitsWith:)` macro implementation
that we emit when we see a nested `#expect()` or `#require()` call.
0 commit comments