test: add flag to retry.
This should allow better handling flaky tests.
This commit is contained in:
parent
126e4c9df1
commit
92a39bc49e
@ -25,6 +25,8 @@ module Homebrew
|
||||
description: "Test the head version of a formula."
|
||||
switch "--keep-tmp",
|
||||
description: "Retain the temporary files created for the test."
|
||||
switch "--retry",
|
||||
description: "Retry if a testing fails."
|
||||
switch :verbose
|
||||
switch :debug
|
||||
conflicts "--devel", "--HEAD"
|
||||
@ -70,7 +72,7 @@ module Homebrew
|
||||
next
|
||||
end
|
||||
|
||||
puts "Testing #{f.full_name}"
|
||||
oh1 "Testing #{f.full_name}"
|
||||
|
||||
env = ENV.to_hash
|
||||
|
||||
@ -108,6 +110,7 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||
retry if retry_test?(f)
|
||||
ofail "#{f.full_name}: failed"
|
||||
puts e, e.backtrace
|
||||
ensure
|
||||
@ -115,4 +118,16 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def retry_test?(f)
|
||||
@test_failed ||= Set.new
|
||||
if args.retry? && @test_failed.add?(f)
|
||||
oh1 "Testing #{f.full_name} (again)"
|
||||
f.clear_cache
|
||||
true
|
||||
else
|
||||
Homebrew.failed = true
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -1036,6 +1036,8 @@ wrong with the installed formula.
|
||||
Test the head version of a formula.
|
||||
* `--keep-tmp`:
|
||||
Retain the temporary files created for the test.
|
||||
* `--retry`:
|
||||
Retry if a testing fails.
|
||||
|
||||
### `tests` [*`options`*]
|
||||
|
||||
|
@ -1351,6 +1351,10 @@ Test the head version of a formula\.
|
||||
\fB\-\-keep\-tmp\fR
|
||||
Retain the temporary files created for the test\.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-retry\fR
|
||||
Retry if a testing fails\.
|
||||
.
|
||||
.SS "\fBtests\fR [\fIoptions\fR]"
|
||||
Run Homebrew\'s unit and integration tests\.
|
||||
.
|
||||
|
Loading…
x
Reference in New Issue
Block a user