Stop createStream for creating additional test runner loops #361
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.
Without this change, every call to
createStream
starts an additional loop of test execution in theResults
instance. Only the first stream creation should start test execution.This was tricky to track down, but in my scenario it was causing the
self.emit('done')
in the loop to fire early (as the additional loop would find no tests waiting, while the prior loop was still executing the last test), which kills the stream (due to theoutput.queue(null)
in thedone
handler), which meant the detection of unfinished tests on theprocess.on('exit'...
handler couldn't write to the stream.The below simple repro shows the problem. Without this change the
console.log
in the stream event handler will never fire. With this change, it does.I couldn't figure out how to turn this into a test case, as it depends on the handling of the process
exit
event. (As noted below, even adding another handler for this doesn't work, as Tape stop the process from running additional handlers in its exit handler).This was found working on improvements to the Tape test running in Visual Studio, which depends on an object stream to report results (microsoft/nodejstools#1524).