Print return code when subprocess fails (MR 2161)

It can be very useful to figure out why a particular subprocess might be
failing ;)
This commit is contained in:
Bart Ribbers 2022-01-21 16:41:18 +01:00
parent ff0942b12d
commit 36aabcc4fe
No known key found for this signature in database
GPG key ID: 0BF4C1B5988C50D8
2 changed files with 5 additions and 3 deletions

View file

@ -1,6 +1,7 @@
# Copyright 2022 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
""" Test pmb.helpers.run_core """
import re
import sys
import subprocess
import pytest
@ -146,13 +147,13 @@ def test_core(args):
# Check the return code
with pytest.raises(RuntimeError) as e:
func(args, msg, ["false"], output="log")
assert str(e.value).startswith("Command failed:")
assert re.search(r"^Command failed \(exit code -?\d*\): ", str(e.value))
# Kill with timeout
args.timeout = 0.2
with pytest.raises(RuntimeError) as e:
func(args, msg, ["sleep", "1"], output="log")
assert str(e.value).startswith("Command failed:")
assert re.search(r"^Command failed \(exit code -?\d*\): ", str(e.value))
@pytest.mark.skip_ci