Skip to content

Commit c186c3c

Browse files
committed
Use mocked notifier for individual tests
That way we separate the collection of notifications from everything else
1 parent 111f086 commit c186c3c

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

tools/build_api.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@ def build_project(src_paths, build_path, target, toolchain_name,
599599
if report != None:
600600
end = time()
601601
cur_result["elapsed_time"] = end - start
602-
cur_result["output"] = notify.get_output() + memap_table
603602
cur_result["result"] = "OK"
604603
cur_result["memory_usage"] = (memap_instance.mem_report
605604
if memap_instance is not None else None)
@@ -622,12 +621,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
622621

623622
cur_result["elapsed_time"] = end - start
624623

625-
toolchain_output = notify.get_output()
626-
if toolchain_output:
627-
cur_result["output"] += toolchain_output
628-
629624
add_result_to_report(report, cur_result)
630-
631625
# Let Exception propagate
632626
raise
633627

@@ -754,7 +748,6 @@ def build_library(src_paths, build_path, target, toolchain_name,
754748
if report != None:
755749
end = time()
756750
cur_result["elapsed_time"] = end - start
757-
cur_result["output"] = notify.get_output()
758751
cur_result["result"] = "OK"
759752

760753

@@ -772,10 +765,6 @@ def build_library(src_paths, build_path, target, toolchain_name,
772765

773766
cur_result["elapsed_time"] = end - start
774767

775-
toolchain_output = notify.get_output()
776-
if toolchain_output:
777-
cur_result["output"] += toolchain_output
778-
779768
add_result_to_report(report, cur_result)
780769

781770
# Let Exception propagate
@@ -926,7 +915,6 @@ def build_lib(lib_id, target, toolchain_name, clean=False, macros=None,
926915
if report != None and needed_update:
927916
end = time()
928917
cur_result["elapsed_time"] = end - start
929-
cur_result["output"] = notify.get_output()
930918
cur_result["result"] = "OK"
931919

932920
add_result_to_report(report, cur_result)
@@ -938,10 +926,6 @@ def build_lib(lib_id, target, toolchain_name, clean=False, macros=None,
938926
cur_result["result"] = "FAIL"
939927
cur_result["elapsed_time"] = end - start
940928

941-
toolchain_output = notify.get_output()
942-
if toolchain_output:
943-
cur_result["output"] += toolchain_output
944-
945929
add_result_to_report(report, cur_result)
946930

947931
# Let Exception propagate
@@ -1085,7 +1069,6 @@ def build_mbed_libs(target, toolchain_name, clean=False, macros=None,
10851069
if report != None:
10861070
end = time()
10871071
cur_result["elapsed_time"] = end - start
1088-
cur_result["output"] = notify.get_output()
10891072
cur_result["result"] = "OK"
10901073

10911074
add_result_to_report(report, cur_result)
@@ -1098,10 +1081,6 @@ def build_mbed_libs(target, toolchain_name, clean=False, macros=None,
10981081
cur_result["result"] = "FAIL"
10991082
cur_result["elapsed_time"] = end - start
11001083

1101-
toolchain_output = notify.get_output()
1102-
if toolchain_output:
1103-
cur_result["output"] += toolchain_output
1104-
11051084
cur_result["output"] += str(exc)
11061085

11071086
add_result_to_report(report, cur_result)

tools/test_api.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import functools
3333
from colorama import Fore, Back, Style
3434
from prettytable import PrettyTable
35-
from copy import copy
35+
from copy import copy, deepcopy
3636

3737
from time import sleep, time
3838
try:
@@ -75,6 +75,7 @@
7575
from tools.utils import argparse_uppercase_type
7676
from tools.utils import argparse_lowercase_type
7777
from tools.utils import argparse_many
78+
from tools.notifier.mock import MockNotifier
7879

7980
import tools.host_tests.host_tests_plugins as host_tests_plugins
8081

@@ -2262,7 +2263,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
22622263
'build_profile': build_profile,
22632264
'toolchain_paths': TOOLCHAIN_PATHS,
22642265
'stats_depth': stats_depth,
2265-
'notify': notify
2266+
'notify': MockNotifier()
22662267
}
22672268

22682269
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,
22852286
worker_result = r.get()
22862287
results.remove(r)
22872288

2289+
# Push all deferred notifications out to the actual notifier
2290+
new_notify = deepcopy(notify)
2291+
for message in worker_result['kwargs']['notify'].messages:
2292+
new_notify.notify(message)
2293+
22882294
# Take report from the kwargs and merge it into existing report
22892295
if report:
22902296
report_entry = worker_result['kwargs']['report'][target_name][toolchain_name]
2297+
report_entry[worker_result['kwargs']['project_id'].upper()][0][0]['output'] = new_notify.get_output()
22912298
for test_key in report_entry.keys():
22922299
report[target_name][toolchain_name][test_key] = report_entry[test_key]
22932300

@@ -2298,6 +2305,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
22982305
result = False
22992306
break
23002307

2308+
23012309
# Adding binary path to test build result
23022310
if ('result' in worker_result and
23032311
worker_result['result'] and
@@ -2313,8 +2321,6 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
23132321
}
23142322

23152323
test_key = worker_result['kwargs']['project_id'].upper()
2316-
if report:
2317-
print(report[target_name][toolchain_name][test_key][0][0]['output'].rstrip())
23182324
print('Image: %s\n' % bin_file)
23192325

23202326
except:

0 commit comments

Comments
 (0)