summaryrefslogtreecommitdiff
path: root/firmware_builder.py
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2020-12-16 09:45:22 -0700
committerCommit Bot <commit-bot@chromium.org>2020-12-17 17:40:10 +0000
commit81ae77c3267fa6fed8fe392b12159d7bbebed0f2 (patch)
treeffab8dc06fd415598fe79052a48ca14913e2fc18 /firmware_builder.py
parentca0d80fb8f42a1982eee03994ec6effa4f636643 (diff)
downloadchrome-ec-81ae77c3267fa6fed8fe392b12159d7bbebed0f2.tar.gz
firmware_builder: use check=True with subprocesses
A little easier to keep this clean (and more pythonic) with exceptions instead of returning error codes. BUG=b:175248887 BRANCH=none TEST=./firmware_builder.py build && ./firmware_builder.py test Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I3764aa5bf3125810e2cacbfc97d9b9d99f6b5aef Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2595809 Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'firmware_builder.py')
-rwxr-xr-xfirmware_builder.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/firmware_builder.py b/firmware_builder.py
index 5f0661e530..428657158b 100755
--- a/firmware_builder.py
+++ b/firmware_builder.py
@@ -24,8 +24,8 @@ def build(opts):
metrics = firmware_pb2.FwBuildMetricList()
with open(opts.metrics, 'w') as f:
f.write(json_format.MessageToJson(metrics))
- return subprocess.run(['make', 'buildall_only', '-j{}'.format(opts.cpus)],
- cwd=os.path.dirname(__file__)).returncode
+ subprocess.run(['make', 'buildall_only', '-j{}'.format(opts.cpus)],
+ cwd=os.path.dirname(__file__), check=True)
def test(opts):
@@ -36,17 +36,15 @@ def test(opts):
f.write(json_format.MessageToJson(metrics))
# Verify all posix-based unit tests build and pass
- rv = subprocess.run(['make', 'runtests', '-j{}'.format(opts.cpus)],
- cwd=os.path.dirname(__file__)).returncode
- if rv != 0:
- return rv
+ subprocess.run(['make', 'runtests', '-j{}'.format(opts.cpus)],
+ cwd=os.path.dirname(__file__), check=True)
# Verify compilation of the on-device unit test binaries.
# TODO(b/172501728) These should build for all boards, but they've bit
# rotted, so we only build the ones that compile.
- return subprocess.run(
+ subprocess.run(
['make', 'BOARD=bloonchipper', 'tests', '-j{}'.format(opts.cpus)],
- cwd=os.path.dirname(__file__)).returncode
+ cwd=os.path.dirname(__file__), check=True)
def main(args):
@@ -58,7 +56,12 @@ def main(args):
return -1
# Run selected sub command function
- return opts.func(opts)
+ try:
+ opts.func(opts)
+ except subprocess.CalledProcessError:
+ return 1
+ else:
+ return 0
def parse_args(args):