Skip to content

Commit

Permalink
Let test_cli produce stack traces in case of errors
Browse files Browse the repository at this point in the history
This should be particularly useful if CLI functions are used that are
unrelated to the function under test. E.g. `test_cli(hash, ...)`
to check the output of a previous CLI invocation.
  • Loading branch information
reneme committed Mar 24, 2023
1 parent 33c6ad9 commit c2abb04
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/scripts/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@ def test_cli(cmd, cmd_options, expected_output=None, cmd_input=None, expected_st

if stderr:
if expected_stderr is None:
logging.error("Got output on stderr %s (stdout was %s) for command %s", stderr, stdout, cmdline)
logging.error("Got output on stderr %s (stdout was %s) for command %s", stderr, stdout, cmdline, stack_info=True)
else:
if stderr != expected_stderr:
logging.error("Got output on stderr %s which did not match expected value %s", stderr, expected_stderr)
logging.error("Got output on stderr %s which did not match expected value %s", stderr, expected_stderr, stack_info=True)
else:
if expected_stderr is not None:
logging.error('Expected output on stderr but got nothing')
logging.error('Expected output on stderr but got nothing', stack_info=True)

if expected_output is not None:
if stdout != expected_output:
logging.error("Got unexpected output running cmd %s %s", cmd, cmd_options)
logging.error("Got unexpected output running cmd %s %s", cmd, cmd_options, stack_info=True)
logging.info("Output lengths %d vs expected %d", len(stdout), len(expected_output))
logging.info("Got %s", stdout)
logging.info("Exp %s", expected_output)
Expand Down

0 comments on commit c2abb04

Please sign in to comment.