Permalink
Browse files

If diff fails give the file names which the diff failed on

  • Loading branch information...
1 parent c10ca0c commit 24dbc0e5442a14c645651cf43b5bab8903abb1db @enebo enebo committed Dec 13, 2012
Showing with 5 additions and 4 deletions.
  1. +5 −4 test/helper.rb
View
9 test/helper.rb
@@ -41,7 +41,8 @@ def run_debugger(testname, args = '', opts = {})
correct_lines = File.read(rightfile).split(/\n/)
filter.call(got_lines, correct_lines) if filter
- if cheap_diff(got_lines, correct_lines)
+ if cheap_diff(File.basename(outfile), File.basename(rightfile),
+ got_lines, correct_lines)
FileUtils.rm(outfile)
return true
end
@@ -59,7 +60,7 @@ def rightfile(testname)
end
end
- def cheap_diff(got_lines, correct_lines)
+ def cheap_diff(out_file, right_file, got_lines, correct_lines)
if $DEBUG
got_lines.each_with_index do |line, i|
printf "%3d %s\n", i+1, line
@@ -68,14 +69,14 @@ def cheap_diff(got_lines, correct_lines)
correct_lines.each_with_index do |line, i|
correct_lines[i].chomp!
if got_lines[i] != correct_lines[i]
- puts "difference found at line #{i+1}"
+ puts "difference found for #{out_file}<->#{right_file} at line #{i+1}"
puts "got : #{got_lines[i]}"
puts "need: #{correct_lines[i]}"
return false
end
end
if correct_lines.size != got_lines.size
- puts("difference in number of lines: " +
+ puts("difference in number of lines for #{out_file}<->#{right_file}: " +
"#{correct_lines.size} vs. #{got_lines.size}")
return false
end

0 comments on commit 24dbc0e

Please sign in to comment.