Handling exceptions throughout test flow

pull/1925/head
Brian Daniels 2016-06-13 23:14:34 +01:00
parent 6796025e78
commit f622c591e8
3 changed files with 40 additions and 26 deletions

View File

@ -30,7 +30,7 @@ from tools.test_api import test_path_to_name, find_tests, print_tests, build_tes
from tools.options import get_default_options_parser
from tools.build_api import build_project, build_library
from tools.targets import TARGET_MAP
from tools.utils import mkdir
from tools.utils import mkdir, ToolException, NotSupportedException
from tools.test_exporters import ReportExporter, ResultExporterType
if __name__ == '__main__':
@ -137,7 +137,7 @@ if __name__ == '__main__':
build_report = {}
build_properties = {}
library_build_success = True
library_build_success = False
try:
# Build sources
build_library(base_source_paths, options.build_dir, target, options.tool,
@ -150,11 +150,21 @@ if __name__ == '__main__':
macros=options.macros,
verbose=options.verbose,
archive=False)
except Exception, e:
library_build_success = False
print "Failed to build library"
if library_build_success:
library_build_success = True
except ToolException, e:
# ToolException output is handled by the build log
pass
except NotSupportedException, e:
# NotSupportedException is handled by the build log
pass
except Exception, e:
# Some other exception occurred, print the error message
print e
if not library_build_success:
print "Failed to build library"
else:
# Build all the tests
test_build_success, test_build = build_tests(tests, [options.build_dir], options.build_dir, target, options.tool,
options=options.options,

View File

@ -2064,7 +2064,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
for test_name, test_path in tests.iteritems():
test_build_path = os.path.join(build_path, test_path)
src_path = base_source_paths + [test_path]
bin_file = None
try:
bin_file = build_project(src_path, test_build_path, target, toolchain_name,
options=options,
@ -2091,6 +2091,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
clean = False
# Normalize the path
if bin_file:
bin_file = os.path.normpath(bin_file)
test_build['tests'][test_name] = {

View File

@ -325,6 +325,7 @@ class ReportExporter():
#test_run = test_result_ext[target][toolchain][test][test_run_number][0]
test_run = test_runner[0]
if "result" in test_run:
if test_run["result"] == "FAIL":
failures.append(test_run)
elif test_run["result"] == "SKIP" or test_run["result"] == "NOT_SUPPORTED":
@ -333,6 +334,8 @@ class ReportExporter():
successes.append(test_run)
else:
raise Exception("Unhandled result type: %s" % (test_run["result"]))
else:
raise Exception("'test_run' did not have a 'result' value")
if successes:
print "\n\nBuild successes:"