Use mocked notifier for individual tests

That way we separate the collection of notifications from everything else
pull/6781/head
Jimmy Brisson 2018-05-03 09:16:26 -05:00
parent 111f086796
commit c186c3ce86
2 changed files with 10 additions and 25 deletions

View File

@ -599,7 +599,6 @@ def build_project(src_paths, build_path, target, toolchain_name,
if report != None: if report != None:
end = time() end = time()
cur_result["elapsed_time"] = end - start cur_result["elapsed_time"] = end - start
cur_result["output"] = notify.get_output() + memap_table
cur_result["result"] = "OK" cur_result["result"] = "OK"
cur_result["memory_usage"] = (memap_instance.mem_report cur_result["memory_usage"] = (memap_instance.mem_report
if memap_instance is not None else None) if memap_instance is not None else None)
@ -622,12 +621,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
cur_result["elapsed_time"] = end - start cur_result["elapsed_time"] = end - start
toolchain_output = notify.get_output()
if toolchain_output:
cur_result["output"] += toolchain_output
add_result_to_report(report, cur_result) add_result_to_report(report, cur_result)
# Let Exception propagate # Let Exception propagate
raise raise
@ -754,7 +748,6 @@ def build_library(src_paths, build_path, target, toolchain_name,
if report != None: if report != None:
end = time() end = time()
cur_result["elapsed_time"] = end - start cur_result["elapsed_time"] = end - start
cur_result["output"] = notify.get_output()
cur_result["result"] = "OK" cur_result["result"] = "OK"
@ -772,10 +765,6 @@ def build_library(src_paths, build_path, target, toolchain_name,
cur_result["elapsed_time"] = end - start cur_result["elapsed_time"] = end - start
toolchain_output = notify.get_output()
if toolchain_output:
cur_result["output"] += toolchain_output
add_result_to_report(report, cur_result) add_result_to_report(report, cur_result)
# Let Exception propagate # Let Exception propagate
@ -926,7 +915,6 @@ def build_lib(lib_id, target, toolchain_name, clean=False, macros=None,
if report != None and needed_update: if report != None and needed_update:
end = time() end = time()
cur_result["elapsed_time"] = end - start cur_result["elapsed_time"] = end - start
cur_result["output"] = notify.get_output()
cur_result["result"] = "OK" cur_result["result"] = "OK"
add_result_to_report(report, cur_result) add_result_to_report(report, cur_result)
@ -938,10 +926,6 @@ def build_lib(lib_id, target, toolchain_name, clean=False, macros=None,
cur_result["result"] = "FAIL" cur_result["result"] = "FAIL"
cur_result["elapsed_time"] = end - start cur_result["elapsed_time"] = end - start
toolchain_output = notify.get_output()
if toolchain_output:
cur_result["output"] += toolchain_output
add_result_to_report(report, cur_result) add_result_to_report(report, cur_result)
# Let Exception propagate # Let Exception propagate
@ -1085,7 +1069,6 @@ def build_mbed_libs(target, toolchain_name, clean=False, macros=None,
if report != None: if report != None:
end = time() end = time()
cur_result["elapsed_time"] = end - start cur_result["elapsed_time"] = end - start
cur_result["output"] = notify.get_output()
cur_result["result"] = "OK" cur_result["result"] = "OK"
add_result_to_report(report, cur_result) add_result_to_report(report, cur_result)
@ -1098,10 +1081,6 @@ def build_mbed_libs(target, toolchain_name, clean=False, macros=None,
cur_result["result"] = "FAIL" cur_result["result"] = "FAIL"
cur_result["elapsed_time"] = end - start cur_result["elapsed_time"] = end - start
toolchain_output = notify.get_output()
if toolchain_output:
cur_result["output"] += toolchain_output
cur_result["output"] += str(exc) cur_result["output"] += str(exc)
add_result_to_report(report, cur_result) add_result_to_report(report, cur_result)

View File

@ -32,7 +32,7 @@ import ctypes
import functools import functools
from colorama import Fore, Back, Style from colorama import Fore, Back, Style
from prettytable import PrettyTable from prettytable import PrettyTable
from copy import copy from copy import copy, deepcopy
from time import sleep, time from time import sleep, time
try: try:
@ -75,6 +75,7 @@ from tools.utils import argparse_filestring_type
from tools.utils import argparse_uppercase_type from tools.utils import argparse_uppercase_type
from tools.utils import argparse_lowercase_type from tools.utils import argparse_lowercase_type
from tools.utils import argparse_many from tools.utils import argparse_many
from tools.notifier.mock import MockNotifier
import tools.host_tests.host_tests_plugins as host_tests_plugins import tools.host_tests.host_tests_plugins as host_tests_plugins
@ -2262,7 +2263,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
'build_profile': build_profile, 'build_profile': build_profile,
'toolchain_paths': TOOLCHAIN_PATHS, 'toolchain_paths': TOOLCHAIN_PATHS,
'stats_depth': stats_depth, 'stats_depth': stats_depth,
'notify': notify 'notify': MockNotifier()
} }
results.append(p.apply_async(build_test_worker, args, kwargs)) results.append(p.apply_async(build_test_worker, args, kwargs))
@ -2285,9 +2286,15 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
worker_result = r.get() worker_result = r.get()
results.remove(r) results.remove(r)
# Push all deferred notifications out to the actual notifier
new_notify = deepcopy(notify)
for message in worker_result['kwargs']['notify'].messages:
new_notify.notify(message)
# Take report from the kwargs and merge it into existing report # Take report from the kwargs and merge it into existing report
if report: if report:
report_entry = worker_result['kwargs']['report'][target_name][toolchain_name] report_entry = worker_result['kwargs']['report'][target_name][toolchain_name]
report_entry[worker_result['kwargs']['project_id'].upper()][0][0]['output'] = new_notify.get_output()
for test_key in report_entry.keys(): for test_key in report_entry.keys():
report[target_name][toolchain_name][test_key] = report_entry[test_key] report[target_name][toolchain_name][test_key] = report_entry[test_key]
@ -2298,6 +2305,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
result = False result = False
break break
# Adding binary path to test build result # Adding binary path to test build result
if ('result' in worker_result and if ('result' in worker_result and
worker_result['result'] and worker_result['result'] and
@ -2313,8 +2321,6 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
} }
test_key = worker_result['kwargs']['project_id'].upper() test_key = worker_result['kwargs']['project_id'].upper()
if report:
print(report[target_name][toolchain_name][test_key][0][0]['output'].rstrip())
print('Image: %s\n' % bin_file) print('Image: %s\n' % bin_file)
except: except: