Created
December 20, 2018 16:06
-
-
Save cyrilchampier/91c94e22f3a119ebaa12a25e57e73136 to your computer and use it in GitHub Desktop.
minitest override for flaky retry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run | |
try_results = [] | |
loop do | |
try_results << super | |
if self.class.disable_retry || try_results.count >= MAX_TRIES || try_results.last.failure.nil? | |
break | |
else | |
reset_state | |
end | |
end | |
if try_results.first.failure.present? && try_results.last.failure.nil? | |
if SentryReporter.enabled? | |
SentryReporter.report(try_results.first, try_results.count) | |
else | |
warn("Test #{try_results.first.class}##{try_results.first.name} is flaky.") | |
end | |
end | |
try_results.last | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment