def diff expect, butwas
output = nil
Tempfile.open("expect") do |a|
a.write(massage(expect))
a.rewind
Tempfile.open("butwas") do |b|
b.write(massage(butwas))
b.rewind
diff_flags = $p ? "" : $c ? "-c" : "-u"
diff_flags += " -b" if $b
result = `#{DIFF} #{diff_flags} #{a.path} #{b.path}`
result.sub!(/^\-\-\- .+/, "--- expected")
result.sub!(/^\+\+\+ .+/, "+++ actual")
output = if result.empty? then
"[no difference--suspect ==]"
else
result.split(/\n/)
end
if $k then
warn "moving #{a.path} to #{a.path}.keep"
File.rename a.path, a.path + ".keep"
warn "moving #{b.path} to #{b.path}.keep"
File.rename b.path, b.path + ".keep"
end
end
end
output
end