From 12dc790ea5b94c758ffa0897a0df19dde0dcf584 Mon Sep 17 00:00:00 2001 From: Tristan Van Berkom Date: Mon, 23 Oct 2017 15:21:27 +0900 Subject: tests/testutils/runcli.py: Optionally make the runner not verbose This is so that we can use it in other contexts than running tests --- tests/testutils/runcli.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/testutils/runcli.py b/tests/testutils/runcli.py index 963af2fe5..056a8486d 100644 --- a/tests/testutils/runcli.py +++ b/tests/testutils/runcli.py @@ -25,10 +25,11 @@ class Result(): class Cli(): - def __init__(self, directory): + def __init__(self, directory, verbose=True): self.directory = directory self.config = None self.cli_runner = CliRunner() + self.verbose = verbose # configure(): # @@ -92,13 +93,14 @@ class Cli(): result = self.cli_runner.invoke(bst_cli, bst_args) # Some informative stdout we can observe when anything fails - command = "bst " + " ".join(bst_args) - print("BuildStream exited with code {} for invocation:\n\t{}" - .format(result.exit_code, command)) - print("Program output was:\n{}".format(result.output)) - - if result.exc_info and result.exc_info[0] != SystemExit: - traceback.print_exception(*result.exc_info) + if self.verbose: + command = "bst " + " ".join(bst_args) + print("BuildStream exited with code {} for invocation:\n\t{}" + .format(result.exit_code, command)) + print("Program output was:\n{}".format(result.output)) + + if result.exc_info and result.exc_info[0] != SystemExit: + traceback.print_exception(*result.exc_info) return Result(result) -- cgit v1.2.1