Skip to content

Commit 6659d2d

Browse files
carlescufikartben
authored andcommitted
scripts: runners: nrfutil: Check return code after Popen
The code invoking nrfutil was not checking the return code of the subprocess, which meant that if the underlying tool was exiting with a failure error code it remained undetected. Signed-off-by: Carles Cufi <[email protected]>
1 parent bfc5094 commit 6659d2d

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

scripts/west_commands/runners/nrfutil.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ def _exec(self, args):
9696
raise subprocess.CalledProcessError(
9797
jout['data']['error']['code'], cmd
9898
)
99+
if p.returncode != 0:
100+
raise subprocess.CalledProcessError(p.returncode, cmd)
99101

100102
return jout_all
101103

scripts/west_commands/tests/test_nrf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ def check_expected(tool, test_case, check_fn, get_snr, tmpdir, runner_config):
414414
def test_init(check_call, popen, get_snr, require, tool, test_case,
415415
runner_config, tmpdir):
416416
popen.return_value.__enter__.return_value.stdout = io.BytesIO(b'')
417+
popen.return_value.__enter__.return_value.returncode = 0
417418

418419
require.side_effect = functools.partial(require_patch, tool)
419420
runner_config = fix_up_runner_config(test_case, runner_config, tmpdir)
@@ -447,6 +448,7 @@ def test_init(check_call, popen, get_snr, require, tool, test_case,
447448
def test_create(check_call, popen, get_snr, require, tool, test_case,
448449
runner_config, tmpdir):
449450
popen.return_value.__enter__.return_value.stdout = io.BytesIO(b'')
451+
popen.return_value.__enter__.return_value.returncode = 0
450452

451453
require.side_effect = functools.partial(require_patch, tool)
452454
runner_config = fix_up_runner_config(test_case, runner_config, tmpdir)

0 commit comments

Comments
 (0)