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:
parent
9e449918a4
commit
db33cc8e56
@ -86,6 +86,9 @@ module Hydra #:nodoc:
|
|||||||
rescue LoadError => ex
|
rescue LoadError => ex
|
||||||
trace "#{file} does not exist [#{ex.to_s}]"
|
trace "#{file} does not exist [#{ex.to_s}]"
|
||||||
return ex.to_s
|
return ex.to_s
|
||||||
|
rescue Exception => ex
|
||||||
|
trace "Error requiring #{file} [#{ex.to_s}]"
|
||||||
|
return ex.to_s
|
||||||
end
|
end
|
||||||
output = []
|
output = []
|
||||||
@result = Test::Unit::TestResult.new
|
@result = Test::Unit::TestResult.new
|
||||||
|
10
test/fixtures/conflicting.rb
vendored
Normal file
10
test/fixtures/conflicting.rb
vendored
Normal 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
|
||||||
|
|
@ -20,6 +20,20 @@ class MasterTest < Test::Unit::TestCase
|
|||||||
assert_equal "HYDRA", File.read(target_file)
|
assert_equal "HYDRA", File.read(target_file)
|
||||||
end
|
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
|
should "run a spec with pending examples" do
|
||||||
progress_bar = Hydra::Listener::ProgressBar.new(StringIO.new)
|
progress_bar = Hydra::Listener::ProgressBar.new(StringIO.new)
|
||||||
Hydra::Master.new(
|
Hydra::Master.new(
|
||||||
|
@ -50,6 +50,10 @@ class Test::Unit::TestCase
|
|||||||
def json_file
|
def json_file
|
||||||
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'json_data.json'))
|
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'json_data.json'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def conflicting_test_file
|
||||||
|
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', 'conflicting.rb'))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module Hydra #:nodoc:
|
module Hydra #:nodoc:
|
||||||
|
Loading…
Reference in New Issue
Block a user