Skip to content

Commit

Permalink
Merge pull request #17 from SpiNNakerManchester/no_log_skip
Browse files Browse the repository at this point in the history
push skip_exceptions one level higher
  • Loading branch information
rowleya committed Jun 29, 2022
2 parents 0787750 + becec88 commit 5413736
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
13 changes: 12 additions & 1 deletion spinnaker_testbase/root_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,29 @@ def report(self, message, file_name):
with open(report_path, "a") as report_file:
report_file.write(message)

def runsafe(self, method, retry_delay=3.0):
def runsafe(self, method, retry_delay=3.0, skip_exceptions=None):
"""
Will run the method possibly a few times
:param method:
:param retry_delay:
:param skip_exceptions:
list to expection classes to convert in SkipTest
:type skip_exceptions: list(class) or None
:return:
"""
if skip_exceptions is None:
skip_exceptions = []
retries = 0
while True:
try:
method()
break
except (JobDestroyedError, SpinnmanException) as ex:
for skip_exception in skip_exceptions:
if isinstance(ex, skip_exception):
raise SkipTest(f"{ex} Still not fixed!") from ex
class_file = sys.modules[self.__module__].__file__
with open(self.error_file(), "a") as error_file:
error_file.write(class_file)
Expand All @@ -109,6 +117,9 @@ def runsafe(self, method, retry_delay=3.0):
except (PacmanValueError, PacmanPartitionException) as ex:
# skip out if on a spin three
self.assert_not_spin_three()
for skip_exception in skip_exceptions:
if isinstance(ex, skip_exception):
raise SkipTest(f"{ex} Still not fixed!") from ex
raise ex
print("")
print("==========================================================")
Expand Down
12 changes: 5 additions & 7 deletions spinnaker_testbase/script_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ def check_script(self, script, broken_msg=None, skip_exceptions=None):
no current usecase known
:param skip_exceptions:
list to expection classes to convert in SkipTest
:type skip_exceptions: list(class)
:type skip_exceptions: list(class) or None
"""
if skip_exceptions is None:
skip_exceptions = []

global script_checker_shown

Expand All @@ -65,17 +63,17 @@ def check_script(self, script, broken_msg=None, skip_exceptions=None):
from runpy import run_path
try:
start = time.time()
self.runsafe(lambda: run_path(script_path))
self.runsafe(lambda: run_path(script_path),
skip_exceptions=skip_exceptions)
duration = time.time() - start
self.report("{} for {}".format(duration, script),
"scripts_ran_successfully")
if plotting:
if not script_checker_shown:
raise SkipTest("{} did not plot".format(script))
except SkipTest:
raise
except Exception as ex: # pylint: disable=broad-except
for skip_exception in skip_exceptions:
if isinstance(ex, skip_exception):
raise SkipTest(f"{ex} Still not fixed!") from ex
if broken_msg:
self.report(script, broken_msg)
else:
Expand Down

0 comments on commit 5413736

Please sign in to comment.