Skip to content

Commit

Permalink
Fix tests (do not re-intercept re-raised exceptions)
Browse files Browse the repository at this point in the history
  • Loading branch information
mexanick committed Jun 20, 2024
1 parent 8fef3fd commit 636d451
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/ctapipe/core/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,13 +452,18 @@ def run(self, argv=None, raises=False):
if raises:
raise
except SystemExit as err:
exit_status = err.code
self.log.exception("Caught SystemExit with exit code %s", exit_status)
Provenance().finish_activity(
activity_name=self.name,
status="partial_success",
exit_code=exit_status,
)
if raises:
raise # do not re-intercept in tests
else:
exit_status = err.code
self.log.exception(
"Caught SystemExit with exit code %s", exit_status
)
Provenance().finish_activity(
activity_name=self.name,
status="partial_success",
exit_code=exit_status,
)
finally:
if not {"-h", "--help", "--help-all"}.intersection(self.argv):
self.write_provenance()
Expand Down

0 comments on commit 636d451

Please sign in to comment.