Log executed command for GUIProcess.

See #797.
This commit is contained in:
Florian Bruhin 2015-09-10 19:25:58 +02:00
parent 729be7e7cc
commit d15cc07ed3
2 changed files with 13 additions and 1 deletions

View File

@ -125,8 +125,9 @@ class GUIProcess(QObject):
raise ValueError("Trying to start a running QProcess!")
self.cmd = cmd
self.args = args
if self.verbose:
fake_cmdline = ' '.join(shlex.quote(e) for e in [cmd] + list(args))
log.procs.debug("Executing: {}".format(fake_cmdline))
if self.verbose:
message.info(self._win_id, 'Executing: ' + fake_cmdline)
def start(self, cmd, args, mode=None):

View File

@ -176,6 +176,17 @@ def test_cmd_args(fake_proc):
assert (fake_proc.cmd, fake_proc.args) == (cmd, args)
def test_start_logging(fake_proc, caplog):
"""Make sure that starting logs the executed commandline."""
cmd = 'does_not_exist'
args = ['arg', 'arg with spaces']
with caplog.atLevel(logging.DEBUG):
fake_proc.start(cmd, args)
msgs = [e.msg for e in caplog.records()]
assert msgs == ["Starting process.",
"Executing: does_not_exist arg 'arg with spaces'"]
def test_error(qtbot, proc, caplog, guiprocess_message_mock):
"""Test the process emitting an error."""
with caplog.atLevel(logging.ERROR, 'message'):