integration_command_test_case: improve fail output

Instead of `puts`ing when the failure occurs save it until the error
message and print a prose description of what the failure was and the
output from the command. This makes the output from failing tests
significantly easier to read.
This commit is contained in:
Mike McQuaid 2017-01-18 08:36:36 +00:00
parent 9f183be358
commit 4d2201b8be

View File

@ -106,16 +106,20 @@ class IntegrationCommandTestCase < Homebrew::TestCase
def cmd(*args) def cmd(*args)
output = cmd_output(*args) output = cmd_output(*args)
status = $?.exitstatus status = $?.exitstatus
puts "\n'brew #{args.join " "}' output: #{output}" if status.nonzero? assert_equal 0, status, <<-EOS.undent
assert_equal 0, status `brew #{args.join " "}` exited with non-zero status!
#{output}
EOS
output output
end end
def cmd_fail(*args) def cmd_fail(*args)
output = cmd_output(*args) output = cmd_output(*args)
status = $?.exitstatus status = $?.exitstatus
$stderr.puts "\n'brew #{args.join " "}'" if status.zero? refute_equal 0, status, <<-EOS.undent
refute_equal 0, status `brew #{args.join " "}` exited with zero status!
#{output}
EOS
output output
end end