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."
|
description: "Test the head version of a formula."
|
||||||
switch "--keep-tmp",
|
switch "--keep-tmp",
|
||||||
description: "Retain the temporary files created for the test."
|
description: "Retain the temporary files created for the test."
|
||||||
|
switch "--retry",
|
||||||
|
description: "Retry if a testing fails."
|
||||||
switch :verbose
|
switch :verbose
|
||||||
switch :debug
|
switch :debug
|
||||||
conflicts "--devel", "--HEAD"
|
conflicts "--devel", "--HEAD"
|
||||||
@ -70,7 +72,7 @@ module Homebrew
|
|||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Testing #{f.full_name}"
|
oh1 "Testing #{f.full_name}"
|
||||||
|
|
||||||
env = ENV.to_hash
|
env = ENV.to_hash
|
||||||
|
|
||||||
@ -108,6 +110,7 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
|
retry if retry_test?(f)
|
||||||
ofail "#{f.full_name}: failed"
|
ofail "#{f.full_name}: failed"
|
||||||
puts e, e.backtrace
|
puts e, e.backtrace
|
||||||
ensure
|
ensure
|
||||||
@ -115,4 +118,16 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
@ -1036,6 +1036,8 @@ wrong with the installed formula.
|
|||||||
Test the head version of a formula.
|
Test the head version of a formula.
|
||||||
* `--keep-tmp`:
|
* `--keep-tmp`:
|
||||||
Retain the temporary files created for the test.
|
Retain the temporary files created for the test.
|
||||||
|
* `--retry`:
|
||||||
|
Retry if a testing fails.
|
||||||
|
|
||||||
### `tests` [*`options`*]
|
### `tests` [*`options`*]
|
||||||
|
|
||||||
|
@ -1351,6 +1351,10 @@ Test the head version of a formula\.
|
|||||||
\fB\-\-keep\-tmp\fR
|
\fB\-\-keep\-tmp\fR
|
||||||
Retain the temporary files created for the test\.
|
Retain the temporary files created for the test\.
|
||||||
.
|
.
|
||||||
|
.TP
|
||||||
|
\fB\-\-retry\fR
|
||||||
|
Retry if a testing fails\.
|
||||||
|
.
|
||||||
.SS "\fBtests\fR [\fIoptions\fR]"
|
.SS "\fBtests\fR [\fIoptions\fR]"
|
||||||
Run Homebrew\'s unit and integration tests\.
|
Run Homebrew\'s unit and integration tests\.
|
||||||
.
|
.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user