Capturing the output of 'testem ci' from a child process (Windows)

126 views
Skip to first unread message

Estelle DeBlois

unread,
Jul 3, 2013, 12:24:54 PM7/3/13
to testem...@googlegroups.com
I'm running into a really strange behavior, and it seems to only happen on Windows (of course).

If I spawn a child process to run `testem ci`, I'm not getting the entirety of the test results in the callback function that executes when the process terminates, through stdout. See the sample code here: https://github.com/brzpegasus/testem-ci-output/blob/master/testem_wrapper.js, hopefully what I'm trying to say will make more sense. Running `testem ci` directly from the command line works just fine. I get the TAP output for each of the tests, plus the summary of passed/failed/total tests at the end. Running `testem ci` with `exec`, I never get the summary output. I thought it might have been a bug with Mocha + Windows as you mentioned there was some issue there, but I observe a similar behavior when switching over to Jasmine.

Given you're more intimately familiar with the code, is there something special with the way testem outputs the results that could explain this behavior? I'll keep looking into it but was hoping you might know something off the top of your head. Thanks!

Estelle DeBlois

unread,
Jul 3, 2013, 1:04:01 PM7/3/13
to testem...@googlegroups.com
I forgot to mention that in this configuration, `testem ci` is launching PhantomJS to execute the tests, though I suppose you can see that from the code comments.

I'm trying to use Mimosa's testem module so I don't have to run 'mimosa watch' in one console, and `testem` in another, and Mimosa does exactly that: create a child process in Node to run `testem ci` then parse the output. Seems to work great, except on Windows because of the output getting cut off thing. It's not a mimosa issue though, and it may very well be a Node + Windows problem. But there's definitely something different, since `exec` runs fine for other commands I tried. Just not testem.

Toby Ho

unread,
Jul 3, 2013, 10:39:42 PM7/3/13
to Estelle DeBlois, testem...@googlegroups.com
Yeah, that sounds familiar. It's a node core bug, but unfortunately as yet unfixed.

the main ticket for this issue is: https://github.com/joyent/node/issues/3584

In short, subprocess' output may not get flushed to the parent process if you call process.exit() in the subprocess.

Toby


On Wed, Jul 3, 2013 at 1:04 PM, Estelle DeBlois <edeb...@gmail.com> wrote:
I forgot to mention that in this configuration, `testem ci` is launching PhantomJS to execute the tests, though I suppose you can see that from the code comments.

I'm trying to use Mimosa's testem module so I don't have to run 'mimosa watch' in one console, and `testem` in another, and Mimosa does exactly that: create a child process in Node to run `testem ci` then parse the output. Seems to work great, except on Windows because of the output getting cut off thing. It's not a mimosa issue though, and it may very well be a Node + Windows problem. But there's definitely something different, since `exec` runs fine for other commands I tried. Just not testem.

--
You received this message because you are subscribed to the Google Groups "Testem Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testem-users...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Estelle DeBlois

unread,
Jul 4, 2013, 12:15:17 PM7/4/13
to testem...@googlegroups.com
Would you be willing to consider patching up calls to process.exit() in testem to force a flush to stdout/stderr before exiting, using the drain/bufferSize check method that other libraries had to resort to, at least until they fix the issue in Node? For 'testem ci' specifically? This would at least allow testem to be used in libraries that need to pipe its console output elsewhere. I'd be happy to open an issue and attempt a PR for this, if you're onboard with the idea.

Toby Ho

unread,
Jul 4, 2013, 5:19:32 PM7/4/13
to Estelle DeBlois, testem...@googlegroups.com
Yeah, as long as there are no negative side effects.

Toby


On Thursday, July 4, 2013, Estelle DeBlois wrote:
Would you be willing to consider patching up calls to process.exit() in testem to force a flush to stdout/stderr before exiting, using the drain/bufferSize check method that other libraries had to resort to, at least until they fix the issue in Node? For 'testem ci' specifically? This would at least allow testem to be used in libraries that need to pipe its console output elsewhere. I'd be happy to open an issue and attempt a PR for this, if you're onboard with the idea.

--
Reply all
Reply to author
Forward
0 new messages