Skip to content
Snippets Groups Projects

Return the last coverage in trace stream

All threads resolved!
1 file
+ 21
1
Compare changes
  • Side-by-side
  • Inline
@@ -73,7 +73,7 @@ def extract_coverage(regex)
match = ""
stream.each_line do |line|
reverse_line do |line|
matches = line.scan(regex)
next unless matches.is_a?(Array)
next if matches.empty?
@@ -115,6 +115,26 @@ def read_last_lines(last_lines)
chunks.join.lines.last(last_lines).join
end
def reverse_line
pos = 0
max = stream.size
while true
pos += BUFFER_SIZE
buf =
if pos <= max
stream.seek(-pos, IO::SEEK_END)
stream.read(BUFFER_SIZE)
else # Reached the head, read only left
stream.seek(0)
stream.read(BUFFER_SIZE - (pos - max))
end
yield(buf)
end
end
end
end
end
Loading