From fbfcd8d3dab8ee3310f8653113a0bbaae16e76f2 Mon Sep 17 00:00:00 2001 From: murphy Date: Wed, 14 Apr 2010 22:38:04 +0000 Subject: Fixed a problem with highlighted diff lines in the output of the scanner suite. --- test/scanners/coderay_suite.rb | 14 ++++++++------ 1 file 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'] -- cgit v1.2.1