Route swift-testing output to /dev/stdout, CONOUT$ #1046
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently we are merging two streams of information to produce swift-testing test output, the JSON event stream written to a named pipe and the stream of data from stdout. This captures both testing events and user outputs produced by things like
print()
statements.However, this approach interleaves the two sources in an arbitrary order. Print statements produced during a test run are typically read after events on the named pipe, which makes it difficult to tell what prints belong to what test.
In order to enforce the correct order we can configure swift-testing to write its events to
/dev/stdout
(orCONOUT$
on Windows). Swift-testing aquires a lock to thefd
it is writing events and output to, so the order of events and prints is correctly enforced.This also simplifies a lot of the code that worked with the JSON event stream as we can now rely solely on the task's stdout/stderr output without the need for named pipes.
When parsing stdout we try and parse a JSON event that matches the swift-testing event schema, and if we fail we print the line directly. If it is parseable, we process it as a swift-testing JSON event and omit it from the test run output.