diff --git a/reframe/frontend/statistics.py b/reframe/frontend/statistics.py index 19353d24a5..0deafd3c78 100644 --- a/reframe/frontend/statistics.py +++ b/reframe/frontend/statistics.py @@ -45,12 +45,18 @@ def retry_report(self): report.append('SUMMARY OF RETRIES') report.append(line_width * '-') messages = {} + for run in range(1, len(self._tasks)): for t in self.get_tasks(run): - key = '%s:%s:%s' % ( - t.check.name, t.check.current_partition.fullname, - t.check.current_environ.name - ) + partition_name = '' + environ_name = '' + if t.check.current_partition: + partition_name = t.check.current_partition.fullname + + if t.check.current_environ: + environ_name = t.check.current_environ.name + + key = '%s:%s:%s' % (t.check.name, partition_name, environ_name) # Overwrite entry from previous run if available messages[key] = ( ' * Test %s was retried %s time(s) and %s.' % diff --git a/unittests/test_policies.py b/unittests/test_policies.py index 4ecf5b869c..9815345328 100644 --- a/unittests/test_policies.py +++ b/unittests/test_policies.py @@ -11,8 +11,8 @@ import unittests.fixtures as fixtures from unittests.resources.checks.hellocheck import HelloTest from unittests.resources.checks.frontend_checks import ( - KeyboardInterruptCheck, SleepCheck, SleepCheckPollFail, - SleepCheckPollFailLate, BadSetupCheck, RetriesCheck, SystemExitCheck) + KeyboardInterruptCheck, SystemExitCheck, SleepCheck, SleepCheckPollFail, + SleepCheckPollFailLate, BadSetupCheck, BadSetupCheckEarly, RetriesCheck) class TestSerialExecutionPolicy(unittest.TestCase): @@ -138,14 +138,17 @@ def test_system_exit_within_test(self): def test_retries_bad_check(self): max_retries = 2 - checks = [BadSetupCheck()] + checks = [BadSetupCheck(), BadSetupCheckEarly()] self.runner._max_retries = max_retries self.runner.runall(checks) # Ensure that the test was retried #max_retries times and failed. - self.assertEqual(1, self.runner.stats.num_cases()) + self.assertEqual(2, self.runner.stats.num_cases()) self.assertEqual(max_retries, rt.runtime().current_run) - self.assertEqual(1, self.runner.stats.num_failures()) + self.assertEqual(2, self.runner.stats.num_failures()) + + # Ensure that the report does not raise any exception. + self.runner.stats.retry_report() def test_retries_good_check(self): max_retries = 2