Closed mexanick closed 2 weeks ago
Project ID: cta-observatory_ctapipe_AY52EYhuvuGcMFidNyUs
Project ID: cta-observatory_ctapipe_AY52EYhuvuGcMFidNyUs
I am somewhat surprised this bugfix ended up being needed as there was a discussion about catching sys.exit(0)
in the original PR and an existing test that checked the behaviour of --help
.
Looking at the pre-existing test it simply checked the return value, which the buggy version didn't change, and forgetting --help
could short circuit is easy enough. My guess is that since @mexanick put his tests in a separate file, neither he nor the reviewers saw the existing test and thus forgot about --help
.
My conclusion is that we need some better guidance on where tests should go, because I don't see a reason why the test code for SystemExit
should be in a separate file instead of inside test_tool_exit_code()
in test_run_tool.py
, and if I hadn't wondered why this bug fix didn't come with a change to the tests I wouldn't have opened test_run_tool.py
by mistake trying to find the existing tests.
I think it's just that before this fix, --help
emitted an ugly systemexit traceback, but also returned 0 (success), so it's hard to check the output for that case. Manually running it of course immediately shows the problem.
@kosack I think the original PR also included a write to the provenance log that didn't happen before the catch to SystemExit
was added, and if the test had checked that the problem would have been caught earlier.
But I with the Provenance log not getting a lot of attention it is understandably why nobody bothered to have a check of its status (is there even easy ways to check its status programmatically?).
The interception of
SystemExit
introduced harmless, but annoying bug: the error message was printed while calling any tool withhelp
option, i.e.:Full log
```shell > ctapipe-quickstart -h Generate quick start files and directory structure. Options ======= The options below are convenience aliases to configurable class-options, as listed in the "Equivalent to" description-line of the aliases. To see all configurable class-options for someWith this fix in case a
SystemExit
with exit code 0 is intercepted, nothing will be done (finally
clause is still honored)