scripts/unit-test.py: Dump the test log if tests fail
Also clean up the redundant handling of the make invocation. If we want
to control make's behaviour, set MAKEFLAGS when calling the script.
Tested: Ran run-unit-test-docker.sh, confirmed log dump on test failure
Change-Id: Ibbc58a2ccfbe92c2e80db82a9ed91a61c7496131
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/scripts/unit-test.py b/scripts/unit-test.py
index 8d7067b..b2ee050 100755
--- a/scripts/unit-test.py
+++ b/scripts/unit-test.py
@@ -9,7 +9,7 @@
from git import Repo
from urlparse import urljoin
-from subprocess import check_call, call
+from subprocess import check_call, call, CalledProcessError
import os
import sys
import argparse
@@ -434,9 +434,9 @@
# Refresh dynamic linker run time bindings for dependencies
check_call_cmd(os.path.join(WORKSPACE, UNIT_TEST_PKG), 'ldconfig')
# Run package unit tests
- if args.verbose:
- check_call_cmd(os.path.join(WORKSPACE, UNIT_TEST_PKG), 'make', 'check',
- 'VERBOSE=1')
- else:
- check_call_cmd(os.path.join(WORKSPACE, UNIT_TEST_PKG), 'make', 'check')
+ try:
+ check_call_cmd(os.path.join(WORKSPACE, UNIT_TEST_PKG), 'make', 'check')
+ except CalledProcessError:
+ check_call_cmd(os.path.join(WORKSPACE, UNIT_TEST_PKG), "cat",
+ os.path.join(WORKSPACE, UNIT_TEST_PKG, "test/test-suite.log"))
os.umask(prev_umask)