From 5e9699042aa1c560e8eb99b7dc428e9cded52b9b Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Sun, 18 Mar 2018 21:21:45 +0100 Subject: [PATCH] Terminate pending task upon abort in serial policy - Also add unit tests to verify this behaviour in both the serial and async execution policy. --- reframe/frontend/executors/policies.py | 4 ++-- reframe/frontend/statistics.py | 5 +++++ unittests/test_policies.py | 13 +++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/reframe/frontend/executors/policies.py b/reframe/frontend/executors/policies.py index c601d3b2bc..48dc4fa9f4 100644 --- a/reframe/frontend/executors/policies.py +++ b/reframe/frontend/executors/policies.py @@ -54,8 +54,8 @@ def run_check(self, check, partition, environ): except TaskExit: return - except ABORT_REASONS: - task.fail(sys.exc_info()) + except ABORT_REASONS as e: + task.abort(e) raise except BaseException: task.fail(sys.exc_info()) diff --git a/reframe/frontend/statistics.py b/reframe/frontend/statistics.py index cbb4b26bd1..f004779a79 100644 --- a/reframe/frontend/statistics.py +++ b/reframe/frontend/statistics.py @@ -19,6 +19,11 @@ def __init__(self, tasks=[]): def __repr__(self): return debug.repr(self) + def alltasks(self): + for tlist in self._tasks_bypart.values(): + for t in tlist: + yield t + def num_failures(self, partition=None): num_fails = 0 if partition: diff --git a/unittests/test_policies.py b/unittests/test_policies.py index be2ef8463d..be616790f6 100644 --- a/unittests/test_policies.py +++ b/unittests/test_policies.py @@ -4,6 +4,7 @@ import reframe.frontend.executors as executors import reframe.frontend.executors.policies as policies +from reframe.core.exceptions import JobNotStartedError from reframe.core.modules import init_modules_system from reframe.frontend.loader import RegressionCheckLoader, SiteConfiguration from reframe.frontend.resources import ResourcesManager @@ -34,6 +35,16 @@ def setUp(self): def tearDown(self): shutil.rmtree(self.resourcesdir, ignore_errors=True) + def assert_all_dead(self): + stats = self.runner.stats + for t in self.runner.stats.alltasks(): + try: + finished = t.check.poll() + except JobNotStartedError: + finished = True + + self.assertTrue(finished) + def test_runall(self): self.runner.runall(self.checks, self.system) @@ -106,6 +117,7 @@ def test_kbd_interrupt_within_test(self): [check], self.system) stats = self.runner.stats self.assertEqual(1, stats.num_failures()) + self.assert_all_dead() def test_system_exit_within_test(self): check = SystemExitCheck(system=self.system, resources=self.resources) @@ -287,6 +299,7 @@ def _run_checks(self, checks, max_jobs): self.assertEqual(4, self.runner.stats.num_cases()) self.assertEqual(4, self.runner.stats.num_failures()) + self.assert_all_dead() def test_kbd_interrupt_in_wait_with_concurrency(self): checks = [