diff --git a/tools/test.py b/tools/test.py index 16e002bee2..9c0d5354a6 100644 --- a/tools/test.py +++ b/tools/test.py @@ -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, diff --git a/tools/test_api.py b/tools/test_api.py index 9872d62316..3ebf7fdf7f 100644 --- a/tools/test_api.py +++ b/tools/test_api.py @@ -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,17 +2091,18 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name, clean = False # Normalize the path - bin_file = os.path.normpath(bin_file) - - test_build['tests'][test_name] = { - "binaries": [ - { - "path": bin_file - } - ] - } - - print 'Image: %s'% bin_file + if bin_file: + bin_file = os.path.normpath(bin_file) + + test_build['tests'][test_name] = { + "binaries": [ + { + "path": bin_file + } + ] + } + + print 'Image: %s'% bin_file test_builds = {} test_builds["%s-%s" % (target.name, toolchain_name)] = test_build diff --git a/tools/test_exporters.py b/tools/test_exporters.py index 857a6bfcd3..6a5aba466e 100644 --- a/tools/test_exporters.py +++ b/tools/test_exporters.py @@ -324,15 +324,18 @@ class ReportExporter(): for test_runner in test_runs: #test_run = test_result_ext[target][toolchain][test][test_run_number][0] test_run = test_runner[0] - - if test_run["result"] == "FAIL": - failures.append(test_run) - elif test_run["result"] == "SKIP" or test_run["result"] == "NOT_SUPPORTED": - skips.append(test_run) - elif test_run["result"] == "OK": - successes.append(test_run) + + 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": + skips.append(test_run) + elif test_run["result"] == "OK": + successes.append(test_run) + else: + raise Exception("Unhandled result type: %s" % (test_run["result"])) else: - raise Exception("Unhandled result type: %s" % (test_run["result"])) + raise Exception("'test_run' did not have a 'result' value") if successes: print "\n\nBuild successes:"