in src/buildstream/_testing/runcli.py [0:0]
def run(self, project=None, silent=False, env=None, cwd=None, options=None, args=None, binary_capture=False):
# We don't want to carry the state of one bst invocation into another
# bst invocation. Since node _FileInfo objects hold onto BuildStream
# projects, this means that they would be also carried forward. This
# becomes a problem when spawning new processes - when pickling the
# state of the node module we will also be pickling elements from
# previous bst invocations.
node._reset_global_state()
if args is None:
args = []
if options is None:
options = []
# We may have been passed e.g. pathlib.Path or py.path
args = [str(x) for x in args]
options = self.default_options + options
with ExitStack() as stack:
bst_args = ["--no-colors"]
if silent:
bst_args += ["--no-verbose"]
config_file = stack.enter_context(configured(self.directory, self.config))
bst_args += ["--config", config_file]
if project:
bst_args += ["--directory", str(project)]
for option, value in options:
bst_args += ["--option", option, value]
bst_args += args
if cwd is not None:
stack.enter_context(chdir(cwd))
if env is not None:
stack.enter_context(environment(env))
result = self._invoke(bst_cli, bst_args, binary_capture=binary_capture)
# Some informative stdout we can observe when anything fails
if self.verbose:
command = "bst " + " ".join(bst_args)
print("BuildStream exited with code {} for invocation:\n\t{}".format(result.exit_code, command))
if result.output:
print("Program output was:\n{}".format(result.output))
if result.stderr:
print("Program stderr was:\n{}".format(result.stderr))
if result.exc_info and result.exc_info[0] != SystemExit:
traceback.print_exception(*result.exc_info)
return result