scripts: runner: let users copy/paste failed commands

Print a copy/pastable version of any command which fails, to help
debugging.

Signed-off-by: Marti Bolivar <marti@opensourcefoundries.com>
This commit is contained in:
Marti Bolivar 2017-11-30 15:04:17 -05:00 committed by Anas Nashif
parent ad8b006bf2
commit 57d5717bc6

View file

@ -412,7 +412,11 @@ class ZephyrBinaryRunner(abc.ABC):
'''
if self.debug:
print(quote_sh_list(cmd))
subprocess.check_call(cmd)
try:
subprocess.check_call(cmd)
except subprocess.CalledProcessError:
print('Error running {}'.format(quote_sh_list(cmd)))
raise
def check_output(self, cmd):
'''Subclass subprocess.check_output() wrapper.
@ -423,7 +427,11 @@ class ZephyrBinaryRunner(abc.ABC):
'''
if self.debug:
print(quote_sh_list(cmd))
return subprocess.check_output(cmd)
try:
return subprocess.check_output(cmd)
except subprocess.CalledProcessError:
print('Error running {}'.format(quote_sh_list(cmd)))
raise
def popen_ignore_int(self, cmd):
'''Spawn a child command, ensuring it ignores SIGINT.