==== //src/ZenTest/dev/lib/unit_diff.rb#19 - /Users/wilson/work/zss/src/ZenTest/dev/lib/unit_diff.rb ==== @@ -82,16 +82,10 @@ output.puts input.gets # the rest of "Finished in..." output.puts next - when /^\s*$/ then + when /^\s*$/, /^\(?\s*\d+\) (Failure|Error):/, /^\d+\)/ then print_lines = false - type = nil current = [] data << current - when /^\(?\s*\d+\) (Failure|Error):/ then - print_lines = false # if line =~ /Failure|Error/ - type = $1 - current = [] - data << current when /^Finished in \d/ then print_lines = false end @@ -111,6 +105,7 @@ header = [] expect = [] butwas = [] + footer = [] found = false state = :header @@ -118,19 +113,43 @@ case state when :header then header << result.shift - state = :expect if result.first =~ /^$/, '') - return header, expect, butwas + return header, expect, butwas, footer end ## @@ -164,12 +183,12 @@ first = [] second = [] - if result.first !~ /Failure/ then + if result.first =~ /Error/ then output.push result.join('') next end - prefix, expect, butwas = parse_diff(result) + prefix, expect, butwas, result_footer = parse_diff(result) output.push prefix.compact.map {|line| line.strip}.join("\n") @@ -188,7 +207,7 @@ if result.empty? then output.push "[no difference--suspect ==]" else - output.push result.split("\n") + output.push result.map { |line| line.chomp } end if $k then @@ -200,6 +219,7 @@ end end + output.push result_footer output.push '' else output.push expect.join('') ==== //src/ZenTest/dev/test/test_unit_diff.rb#11 - /Users/wilson/work/zss/src/ZenTest/dev/test/test_unit_diff.rb ==== @@ -25,6 +25,85 @@ util_unit_diff(header, input, expected, :parse_input) end + def test_input_mini_rspec + header = <<-HEADER +Started +.......F +Finished in 0.1 seconds + + HEADER + + failure = <<-FAILURE +1) +The unless expression should fail FAILED +Expected nil to equal "baz": + FAILURE + + backtrace = <<-BACKTRACE + PositiveExpectation#== at spec/mini_rspec.rb:217 + main.__script__ {} at spec/language/unless_spec.rb:49 + Proc#call at kernel/core/proc.rb:127 + SpecRunner#it at spec/mini_rspec.rb:368 + main.it at spec/mini_rspec.rb:412 + main.__script__ {} at spec/language/unless_spec.rb:48 + Proc#call at kernel/core/proc.rb:127 + SpecRunner#describe at spec/mini_rspec.rb:378 + main.describe at spec/mini_rspec.rb:408 + main.__script__ at spec/language/unless_spec.rb:3 + CompiledMethod#as_script at kernel/bootstrap/primitives.rb:41 + main.load at kernel/core/compile.rb:150 + main.__script__ {} at last_mspec.rb:11 + Array#each {} at kernel/core/array.rb:545 + Integer(Fixnum)#times at kernel/core/integer.rb:15 + Array#each at kernel/core/array.rb:545 + main.__script__ at last_mspec.rb:16 + CompiledMethod#as_script at kernel/bootstrap/primitives.rb:41 + main.load at kernel/core/compile.rb:150 + main.__script__ at kernel/loader.rb:145 + BACKTRACE + + footer = "\n8 examples, 1 failures\n" + input = header + failure + backtrace + footer + + expected_backtrace = backtrace.split("\n").map {|l| "#{l}\n"} + expected = [[["1)\n", "The unless expression should fail FAILED\n", + "Expected nil to equal \"baz\":\n", + *expected_backtrace]], + ["\n", "8 examples, 1 failures\n"]] + util_unit_diff(header, input, expected, :parse_input) + end + + def test_input_mini_rspec_multiline + header = <<-HEADER +Started +.......F +Finished in 0.1 seconds + + HEADER + +failure = <<-FAILURE +1) +Compiler compiles a case without an argument FAILED +Expected #], [:push_literal, "foo"], [:string_dup], [:goto, #