Added more meaningful output when a test dies before it can be run
This commit is contained in:
parent
db33cc8e56
commit
fbd1e9f6e2
|
@ -79,6 +79,14 @@ module Hydra #:nodoc:
|
|||
end
|
||||
end
|
||||
|
||||
def format_ex_in_file(file, ex)
|
||||
"Error in #{file}:\n #{format_exception(ex)}"
|
||||
end
|
||||
|
||||
def format_exception(ex)
|
||||
"#{ex.class.name}: #{ex.message}\n #{ex.backtrace.join("\n ")}"
|
||||
end
|
||||
|
||||
# Run all the Test::Unit Suites in a ruby file
|
||||
def run_test_unit_file(file)
|
||||
begin
|
||||
|
@ -88,7 +96,7 @@ module Hydra #:nodoc:
|
|||
return ex.to_s
|
||||
rescue Exception => ex
|
||||
trace "Error requiring #{file} [#{ex.to_s}]"
|
||||
return ex.to_s
|
||||
return format_ex_in_file(file, ex)
|
||||
end
|
||||
output = []
|
||||
@result = Test::Unit::TestResult.new
|
||||
|
@ -100,7 +108,7 @@ module Hydra #:nodoc:
|
|||
begin
|
||||
klasses.each{|klass| klass.suite.run(@result){|status, name| ;}}
|
||||
rescue => ex
|
||||
output << ex.to_s
|
||||
output << format_ex_in_file(file, ex)
|
||||
end
|
||||
|
||||
return output.join("\n")
|
||||
|
|
|
@ -23,13 +23,28 @@ class MasterTest < Test::Unit::TestCase
|
|||
# this test simulates what happens when we have 2 tests with the same
|
||||
# class name but with different parent classes. This can happen when
|
||||
# we have a functional and an integration test class with the same name.
|
||||
should "run even with a test that is invalidwill not require" do
|
||||
should "run even with a test that will not require" do
|
||||
class FileOutputListener < Hydra::Listener::Abstract
|
||||
attr_accessor :output
|
||||
def initialize(&block)
|
||||
self.output = {}
|
||||
end
|
||||
|
||||
def file_end(file, output)
|
||||
self.output[file] = output
|
||||
end
|
||||
end
|
||||
|
||||
listener = FileOutputListener.new
|
||||
sync_test = File.join(File.dirname(__FILE__), 'fixtures', 'sync_test.rb')
|
||||
Hydra::Master.new(
|
||||
# we want the actual test to run last to make sure the runner can still run tests
|
||||
:files => [sync_test, conflicting_test_file, test_file],
|
||||
:autosort => false
|
||||
:autosort => false,
|
||||
:listeners => [listener]
|
||||
)
|
||||
assert_match /superclass mismatch for class SyncTest/, listener.output[conflicting_test_file]
|
||||
assert_match conflicting_test_file, listener.output[conflicting_test_file]
|
||||
assert File.exists?(target_file)
|
||||
assert_equal "HYDRA", File.read(target_file)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue