Fixed runner crash if a test file cannot properly be required. This can

happen for instance when two test classes have the same name but different
super classes.
This commit is contained in:
Sean Kirby 2010-08-27 22:35:11 -04:00
parent 9e449918a4
commit db33cc8e56
4 changed files with 31 additions and 0 deletions

View File

@ -86,6 +86,9 @@ module Hydra #:nodoc:
rescue LoadError => ex
trace "#{file} does not exist [#{ex.to_s}]"
return ex.to_s
rescue Exception => ex
trace "Error requiring #{file} [#{ex.to_s}]"
return ex.to_s
end
output = []
@result = Test::Unit::TestResult.new

10
test/fixtures/conflicting.rb vendored Normal file
View File

@ -0,0 +1,10 @@
require File.join(File.dirname(__FILE__), '..', 'test_helper')
# this test is around to make sure that we handle all the errors
# that can occur when 'require'ing a test file.
class SyncTest < Object
def test_it_again
assert true
end
end

View File

@ -20,6 +20,20 @@ class MasterTest < Test::Unit::TestCase
assert_equal "HYDRA", File.read(target_file)
end
# 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
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
)
assert File.exists?(target_file)
assert_equal "HYDRA", File.read(target_file)
end
should "run a spec with pending examples" do
progress_bar = Hydra::Listener::ProgressBar.new(StringIO.new)
Hydra::Master.new(

View File

@ -50,6 +50,10 @@ class Test::Unit::TestCase
def json_file
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'json_data.json'))
end
def conflicting_test_file
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'conflicting.rb'))
end
end
module Hydra #:nodoc: