Skip to content

Commit

Permalink
Bug fix: coverage hangs for large files
Browse files Browse the repository at this point in the history
The code that used IO.pipe & ChildProcess to run istanbul was waiting for the process to finish before reading the result.  With a file whose instrumentation is large enough to exceed the system IO buffer size, the istanbul process would block and we'd have deadlock.  Rather than fixing that using the appropriate nonblocking reading, just switched to %x[]
  • Loading branch information
ronen committed Feb 4, 2013
1 parent 689dc48 commit b45aca0
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/guard/jasmine/coverage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@ def evaluate(context, locals)

File.write input, data

r, w = IO.pipe
proc = ChildProcess.build(JasmineCoverage.coverage_bin, 'instrument', '--embed-source', input)
proc.io.stdout = proc.io.stderr = w
proc.start
proc.wait
w.close
result = %x[#{JasmineCoverage.coverage_bin} instrument --embed-source #{input.shellescape}]

raise "Could not generate coverage instrumented file for #{ file }" unless proc.exit_code == 0
raise "Could not generate coverage instrumented file for #{ file }" unless $?.exitstatus == 0

result.gsub input, file

r.read.gsub input, file
end
end

Expand Down

0 comments on commit b45aca0

Please sign in to comment.