diff options
author | murphy <murphy@rubychan.de> | 2010-04-14 22:38:04 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2010-04-14 22:38:04 +0000 |
commit | fbfcd8d3dab8ee3310f8653113a0bbaae16e76f2 (patch) | |
tree | eff36411c1306d66c6d32a472f1165b636c9b8ca | |
parent | b67199122b99b9d5c813d43d3015e5eb2ed2dd36 (diff) | |
download | coderay-fbfcd8d3dab8ee3310f8653113a0bbaae16e76f2.tar.gz |
Fixed a problem with highlighted diff lines in the output of the scanner suite.
-rw-r--r-- | test/scanners/coderay_suite.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/test/scanners/coderay_suite.rb b/test/scanners/coderay_suite.rb index aa46f9b..3fd7201 100644 --- a/test/scanners/coderay_suite.rb +++ b/test/scanners/coderay_suite.rb @@ -336,18 +336,20 @@ module CodeRay actual_filename = expected_filename.sub('.expected.', '.actual.') File.open(actual_filename, 'wb') { |f| f.write result } diff = expected_filename.sub(/\.expected\..*/, '.debug.diff') - system "diff --unified=1 --text #{expected_filename} #{actual_filename} > #{diff}" - changed_lines = [] + system "diff --unified=0 --text #{expected_filename} #{actual_filename} > #{diff}" debug_diff = File.read diff - File.open diff + '.html', 'wb' do |f| - f.write Highlighter.encode_tokens(CodeRay.scan(debug_diff, :diff), - :title => "#{self.class.name[/\w+$/]}: #{name}, differences from expected output") - end + changed_lines = [] debug_diff.scan(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/) do |offset, size| offset = offset.to_i size = (size || 1).to_i changed_lines.concat Array(offset...offset + size) end + system "diff --unified=0 --text #{expected_filename} #{actual_filename} > #{diff}" + debug_diff = File.read diff + File.open diff + '.html', 'wb' do |f| + f.write Highlighter.encode_tokens(CodeRay.scan(debug_diff, :diff), + :title => "#{self.class.name[/\w+$/]}: #{name}, differences from expected output") + end end assert(ok, "Scan error: unexpected output".red) if ENV['assert'] |