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 ""
|
warn ""
|
||||||
@warnings.uniq! {|w| w[1].message}
|
@warnings.uniq! {|w| w[1].message}
|
||||||
@warnings.each do |w|
|
@warnings.each do |w|
|
||||||
|
@errors += 1
|
||||||
warn "#{w[0]}: #{w[1].message} (#{w[1].class})"
|
warn "#{w[0]}: #{w[1].message} (#{w[1].class})"
|
||||||
end
|
end
|
||||||
warn ""
|
warn ""
|
||||||
@ -1282,8 +1283,13 @@ module Test
|
|||||||
puts "#{f}: #{$!}"
|
puts "#{f}: #{$!}"
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
@load_failed = errors.size.nonzero?
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def run(*)
|
||||||
|
super or @load_failed
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
module RepeatOption # :nodoc: all
|
module RepeatOption # :nodoc: all
|
||||||
@ -1680,7 +1686,7 @@ module Test
|
|||||||
break unless report.empty?
|
break unless report.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
return failures + errors if self.test_count > 0 # or return nil...
|
return (failures + errors).nonzero? # or return nil...
|
||||||
rescue Interrupt
|
rescue Interrupt
|
||||||
abort 'Interrupted'
|
abort 'Interrupted'
|
||||||
end
|
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