-
Notifications
You must be signed in to change notification settings - Fork 7
Description
I noticed that Guard::MochaNode works fine on line-based Mocha reporters (list, spec, etc) but that with single-line character-based reporters (dot, progress, etc), it buffers the entire line, which kinda defeats the purpose of these reporters.
After looking around I found the culprit is here: https://github.com/kanzeon/guard-mocha-node/blob/master/lib/guard/mocha_node/spec_state.rb#L24
I'm a little puzzled, because the gem version I've installed with Bundler has this on those lines:
# stream stdout immediately
until @stdout.eof?
line = @stdout.gets
print line if !line.strip.empty?
endwhereas the version in this repo has this:
@stdout.lines { |line| print line if !line.strip.empty? }Is @neerolyte now pushing this gem to rubygems.org via https://github.com/neerolyte/guard-mocha-node/ ? If so, I don't have a way to report this issue directly, as he doesn't have issues enabled on his fork.
Anyway, I found a relatively easy fix to the problem, which is to print mocha's output one character at a time.
# stream stdout immediately
until @stdout.eof?
output = @stdout.getc
$stdout.putc output
endAlthough that made me wonder, why is Guard::MochaNode separating the stdout and stderr output from mocha? Would there be a disadvantage of using Kernel#system instead of Open3.popen3 in the runner here: https://github.com/kanzeon/guard-mocha-node/blob/master/lib/guard/mocha_node/runner.rb#L27 - and just let mocha take responsibility for sequencing the output?