Closed r0mflip closed 5 years ago
Is there perhaps something the command line code for tap-spec is doing that your programmatic version isn’t?
I've checked and experimented, its totally the same. The only thing is when and how the stream ends.
tap-spec
uses tap-out
as a parser. tap-out
listens for the end of the stream and emits an output
event. That event tap-spec
uses to print the count of tests, passed failed etc.
I've debudded it using breakpoints. The event is never fired, tap-out
just waits for the stream to end and meanwhile the whole process exits. The process was just exiting. When I debugged tap-spec
as a js file and passing input to it through stdin
, it worked correctly.
tap-spec
taking in input is the same as programatic one but the input is from stdin
.
P.S.: I hardly understand whats happening inside tape, but came to infer that the stream is closed on process exit from this
The streams stuff is the part of tape I'm least familiar with, unfortunately.
I'd be happy to review a PR - even just one containing failing tests would be helpful.
I'll see what I can do. I have a few ideas in mind but that might end up changing the API a bit.
@ljharb Made PR #466. Sorry for the delay, I had exams 😁
The stream created by
tape.createStream()
is closed on process exit. Until the process exits theclose
event on the stream won't fire. This is causing issues with tap consumer programs liketap-spec
andtap-out
where they cannot hook into theend
orclose
event of the stream.Consider this where
add
pases andmultiply
fails:I get the output:
Whereas when I use
tap-spec
from command line (removing programatic pipe)node test/test.js | tap-spec
I get:The results in the bottom are obtained by
tap-out
on theclose
event of the stream. When run theclose
event on the stream won't fire until before the whole process exits, at which pointtap-out
stops working. In command line usage the streamclose
event fires as it is fromstdin
and still thetap-out
ortap-spec
process would be alive.Is there a solution to this problem or should I be just pipe my tap output to other programs.