Exit with a failure if any test files failed to load
This commit is contained in:
parent
1bb7c3c447
commit
4589056384
Notes:
git
2023-06-03 11:22:30 +00:00
@ -813,6 +813,7 @@ module Test
|
||||
warn ""
|
||||
@warnings.uniq! {|w| w[1].message}
|
||||
@warnings.each do |w|
|
||||
@errors += 1
|
||||
warn "#{w[0]}: #{w[1].message} (#{w[1].class})"
|
||||
end
|
||||
warn ""
|
||||
@ -1282,8 +1283,13 @@ module Test
|
||||
puts "#{f}: #{$!}"
|
||||
end
|
||||
}
|
||||
@load_failed = errors.size.nonzero?
|
||||
result
|
||||
end
|
||||
|
||||
def run(*)
|
||||
super or @load_failed
|
||||
end
|
||||
end
|
||||
|
||||
module RepeatOption # :nodoc: all
|
||||
@ -1680,7 +1686,7 @@ module Test
|
||||
break unless report.empty?
|
||||
end
|
||||
|
||||
return failures + errors if self.test_count > 0 # or return nil...
|
||||
return (failures + errors).nonzero? # or return nil...
|
||||
rescue Interrupt
|
||||
abort 'Interrupted'
|
||||
end
|
||||
|
1
tool/test/testunit/test4test_load_failure.rb
Normal file
1
tool/test/testunit/test4test_load_failure.rb
Normal file
@ -0,0 +1 @@
|
||||
raise LoadError, "no-such-library"
|
23
tool/test/testunit/test_load_failure.rb
Normal file
23
tool/test/testunit/test_load_failure.rb
Normal file
@ -0,0 +1,23 @@
|
||||
# frozen_string_literal: true
|
||||
require 'test/unit'
|
||||
|
||||
class TestLoadFailure < Test::Unit::TestCase
|
||||
def test_load_failure
|
||||
assert_not_predicate(load_failure, :success?)
|
||||
end
|
||||
|
||||
def test_load_failure_parallel
|
||||
assert_not_predicate(load_failure("-j2"), :success?)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_failure(*args)
|
||||
IO.popen([*@options[:ruby], "#{__dir__}/../runner.rb",
|
||||
"#{__dir__}/test4test_load_failure.rb",
|
||||
"--verbose", *args], err: [:child, :out]) {|f|
|
||||
assert_include(f.read, "test4test_load_failure.rb")
|
||||
}
|
||||
$?
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user