Commit acf4a9c0 authored by Nick Thomas's avatar Nick Thomas
Browse files

Fix the gcovr coverage regex by removing line separators before scanning

RE2 differs from Ruby in handling multiple-line strings. The string "foo\n"
will not match the regular expression "foo$" unless multi-line mode is enabled
(and it's off by default).

Since we're already scanning the build trace line by line (and so multi-line
coverage regular expressions won't work), we can fix this by removing the line
separator before scanning the string.
parent 75ba3e432b08
...@@ -74,6 +74,7 @@ ...@@ -74,6 +74,7 @@
match = "" match = ""
reverse_line do |line| reverse_line do |line|
matches = regex.scan(line) matches = regex.scan(line)
next unless matches.is_a?(Array) next unless matches.is_a?(Array)
next if matches.empty? next if matches.empty?
...@@ -300,5 +300,12 @@ ...@@ -300,5 +300,12 @@
include_examples 'malicious regexp' include_examples 'malicious regexp'
end end
context 'multi-line data with rooted regexp' do
let(:data) { "\n65%\n" }
let(:regex) { '^(\d+)\%$' }
it { eq('65') }
end end
end end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment