summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-10-23 15:21:27 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-10-23 15:28:07 +0900
commit12dc790ea5b94c758ffa0897a0df19dde0dcf584 (patch)
tree99e42bc2b49d76407ae7582c0453dadb70d3dc1b
parent30d98319728b52d83e1e112e8b4378388427bd52 (diff)
downloadbuildstream-12dc790ea5b94c758ffa0897a0df19dde0dcf584.tar.gz
tests/testutils/runcli.py: Optionally make the runner not verbose
This is so that we can use it in other contexts than running tests
-rw-r--r--tests/testutils/runcli.py18
1 files 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)