sanitycheck: do not retry build errors with --retry-failed

restore how --only-failed works by allow rebuilds in case of build
errors, however, do not rebuild when --retry-failed is used, which is a
CI usecase and nothing would change in the second iteration.

Fixes #26685

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2020-07-09 09:46:45 -04:00
commit dc43c298a2
2 changed files with 17 additions and 7 deletions

View file

@ -2092,6 +2092,8 @@ class ProjectBuilder(FilterBuilder):
instance = self.instance
if instance.status in ["error", "failed", "timeout"]:
if instance.status == "error":
self.suite.total_errors += 1
self.suite.total_failed += 1
if self.verbose:
status = Fore.RED + "FAILED " + Fore.RESET + instance.reason
@ -2110,6 +2112,7 @@ class ProjectBuilder(FilterBuilder):
self.suite.total_skipped += 1
status = Fore.YELLOW + "SKIPPED" + Fore.RESET
elif instance.status == "passed":
self.suite.total_passed += 1
status = Fore.GREEN + "PASSED" + Fore.RESET
else:
logger.debug(f"Unknown status = {instance.status}")
@ -2312,6 +2315,8 @@ class TestSuite(DisablePyTestCollectionMixin):
self.total_done = 0 # tests completed
self.total_failed = 0
self.total_skipped = 0
self.total_passed = 0
self.total_errors = 0
self.total_platforms = 0
self.start_time = 0
@ -2420,7 +2425,7 @@ class TestSuite(DisablePyTestCollectionMixin):
run += 1
if self.total_tests and self.total_tests != self.total_skipped:
pass_rate = (float(self.total_tests - self.total_failed - self.total_skipped) / float(
pass_rate = (float(self.total_passed) / float(
self.total_tests - self.total_skipped))
else:
pass_rate = 0
@ -2428,7 +2433,7 @@ class TestSuite(DisablePyTestCollectionMixin):
logger.info(
"{}{} of {}{} tests passed ({:.2%}), {}{}{} failed, {} skipped with {}{}{} warnings in {:.2f} seconds".format(
Fore.RED if failed else Fore.GREEN,
self.total_tests - self.total_failed - self.total_skipped,
self.total_passed,
self.total_tests - self.total_skipped,
Fore.RESET,
pass_rate,
@ -2844,13 +2849,14 @@ class TestSuite(DisablePyTestCollectionMixin):
if instance.run:
pipeline.put({"op": "run", "test": instance, "status": "built"})
else:
if instance.status not in ['passed', 'skipped']:
if instance.status not in ['passed', 'skipped', 'error']:
instance.status = None
pipeline.put({"op": "cmake", "test": instance})
return "DONE FEEDING"
def execute(self):
def calc_one_elf_size(instance):
if instance.status not in ["error", "failed", "skipped"]:
if instance.platform.type != "native":

View file

@ -304,6 +304,10 @@ Artificially long but functional example:
"--retry-failed", type=int, default=0,
help="Retry failing tests again, up to the number of times specified.")
parser.add_argument(
"--retry-interval", type=int, default=60,
help="Retry failing tests after specified period of time.")
test_xor_subtest = case_select.add_mutually_exclusive_group()
test_xor_subtest.add_argument(
@ -935,7 +939,7 @@ def main():
last_run = os.path.join(options.outdir, "sanitycheck.csv")
if options.only_failed:
suite.load_from_file(last_run, filter_status=['error', 'skipped', 'passed'])
suite.load_from_file(last_run, filter_status=['skipped', 'passed'])
suite.selected_platforms = set(p.platform.name for p in suite.instances.values())
elif options.load_tests:
suite.load_from_file(options.load_tests)
@ -1065,15 +1069,15 @@ def main():
if completed > 1:
logger.info("%d Iteration:" % (completed))
time.sleep(60) # waiting for the system to settle down
time.sleep(options.retry_interval) # waiting for the system to settle down
suite.total_done = suite.total_tests - suite.total_failed
suite.total_failed = 0
suite.total_failed = suite.total_errors
suite.execute()
print("")
retries = retries - 1
if retries == 0 or suite.total_failed == 0:
if retries == 0 or suite.total_failed == suite.total_errors:
break
suite.misc_reports(options.compare_report, options.show_footprint,