Skip to content

Commit b3239a4

Browse files
authored
Merge pull request #221 from bridadan/test-building-changes
Test building behavior and log changes
2 parents e0b314c + 71fe5e8 commit b3239a4

File tree

5 files changed

+41
-40
lines changed

5 files changed

+41
-40
lines changed

tools/build_api.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,9 @@ def build_project(src_path, build_path, target, toolchain_name,
207207
resources.objects.extend(objects)
208208

209209
# Link Program
210-
res, needed_update = toolchain.link_program(resources, build_path, name)
210+
res, _ = toolchain.link_program(resources, build_path, name)
211211

212-
if report != None and needed_update:
212+
if report != None:
213213
end = time()
214214
cur_result["elapsed_time"] = end - start
215215
cur_result["output"] = toolchain.get_output()
@@ -234,8 +234,6 @@ def build_project(src_path, build_path, target, toolchain_name,
234234
if toolchain_output:
235235
cur_result["output"] += toolchain_output
236236

237-
cur_result["output"] += str(e)
238-
239237
add_result_to_report(report, cur_result)
240238

241239
# Let Exception propagate
@@ -360,11 +358,9 @@ def build_library(src_paths, build_path, target, toolchain_name,
360358
resources.objects.extend(objects)
361359

362360
if archive:
363-
needed_update = toolchain.build_library(resources.objects, build_path, name)
364-
else:
365-
needed_update = True
361+
toolchain.build_library(objects, build_path, name)
366362

367-
if report != None and needed_update:
363+
if report != None:
368364
end = time()
369365
cur_result["elapsed_time"] = end - start
370366
cur_result["output"] = toolchain.get_output()
@@ -511,12 +507,12 @@ def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=F
511507
for o in separate_objects:
512508
objects.remove(o)
513509

514-
needed_update = toolchain.build_library(objects, BUILD_TOOLCHAIN, "mbed")
510+
toolchain.build_library(objects, BUILD_TOOLCHAIN, "mbed")
515511

516512
for o in separate_objects:
517513
toolchain.copy_files(o, BUILD_TOOLCHAIN)
518514

519-
if report != None and needed_update:
515+
if report != None:
520516
end = time()
521517
cur_result["elapsed_time"] = end - start
522518
cur_result["output"] = toolchain.get_output()

tools/test.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
parser.add_option("-f", "--format", type="choice", dest="format",
6767
choices=format_choices, default=format_default_choice, help=format_help)
6868

69+
parser.add_option("--continue-on-build-fail", action="store_true", dest="continue_on_build_fail",
70+
default=None, help="Continue trying to build all tests if a build failure occurs")
71+
6972
parser.add_option("-n", "--names", dest="names",
7073
default=None, help="Limit the tests to a comma separated list of names")
7174

@@ -157,7 +160,8 @@
157160
properties=build_properties,
158161
macros=options.macros,
159162
verbose=options.verbose,
160-
jobs=options.jobs)
163+
jobs=options.jobs,
164+
continue_on_build_fail=options.continue_on_build_fail)
161165

162166
# If a path to a test spec is provided, write it to a file
163167
if options.test_spec:
@@ -181,7 +185,10 @@
181185
report_exporter = ReportExporter(ResultExporterType.JUNIT, package="build")
182186
report_exporter.report_to_file(build_report, options.build_report_junit, test_suite_properties=build_properties)
183187

184-
if library_build_success and test_build_success:
188+
print_report_exporter = ReportExporter(ResultExporterType.PRINT, package="build")
189+
status = print_report_exporter.report(build_report)
190+
191+
if status:
185192
sys.exit(0)
186193
else:
187194
sys.exit(1)

tools/test_api.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,7 +2042,8 @@ def print_tests(tests, format="list"):
20422042

20432043
def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
20442044
options=None, clean=False, notify=None, verbose=False, jobs=1,
2045-
macros=None, silent=False, report=None, properties=None):
2045+
macros=None, silent=False, report=None, properties=None,
2046+
continue_on_build_fail=False):
20462047
"""Given the data structure from 'find_tests' and the typical build parameters,
20472048
build all the tests
20482049
@@ -2077,7 +2078,11 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
20772078

20782079
except Exception, e:
20792080
result = False
2080-
continue
2081+
2082+
if continue_on_build_fail:
2083+
continue
2084+
else:
2085+
break
20812086

20822087
# If a clean build was carried out last time, disable it for the next build.
20832088
# Otherwise the previously built test will be deleted.

tools/test_exporters.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from tools.utils import construct_enum, mkdir
2121
import os
2222

23-
2423
ResultExporterType = construct_enum(HTML='Html_Exporter',
2524
JUNIT='JUnit_Exporter',
2625
JUNIT_OPER='JUnit_Exporter_Interoperability',
@@ -73,7 +72,8 @@ def __init__(self, result_exporter_type, package="test"):
7372
self.result_exporter_type = result_exporter_type
7473
self.package = package
7574

76-
def report(self, test_summary_ext, test_suite_properties=None):
75+
def report(self, test_summary_ext, test_suite_properties=None,
76+
print_log_for_failures=True):
7777
""" Invokes report depending on exporter_type set in constructor
7878
"""
7979
if self.result_exporter_type == ResultExporterType.HTML:
@@ -87,7 +87,7 @@ def report(self, test_summary_ext, test_suite_properties=None):
8787
return self.exporter_junit_ioper(test_summary_ext, test_suite_properties)
8888
elif self.result_exporter_type == ResultExporterType.PRINT:
8989
# JUNIT exporter for interoperability test
90-
return self.exporter_print(test_summary_ext)
90+
return self.exporter_print(test_summary_ext, print_log_for_failures=print_log_for_failures)
9191
return None
9292

9393
def report_to_file(self, test_summary_ext, file_name, test_suite_properties=None):
@@ -297,11 +297,15 @@ def exporter_junit(self, test_result_ext, test_suite_properties=None):
297297
test_suites.append(ts)
298298
return TestSuite.to_xml_string(test_suites)
299299

300-
def exporter_print_helper(self, array):
300+
def exporter_print_helper(self, array, print_log=False):
301301
for item in array:
302302
print " * %s::%s::%s" % (item["target_name"], item["toolchain_name"], item["id"])
303+
if print_log:
304+
log_lines = item["output"].split("\n")
305+
for log_line in log_lines:
306+
print " %s" % log_line
303307

304-
def exporter_print(self, test_result_ext):
308+
def exporter_print(self, test_result_ext, print_log_for_failures=False):
305309
""" Export test results in print format.
306310
"""
307311
failures = []
@@ -340,7 +344,7 @@ def exporter_print(self, test_result_ext):
340344

341345
if failures:
342346
print "\n\nBuild failures:"
343-
self.exporter_print_helper(failures)
347+
self.exporter_print_helper(failures, print_log=print_log_for_failures)
344348
return False
345349
else:
346350
return True

tools/toolchains/gcc.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class GCC(mbedToolchain):
2828

2929
STD_LIB_NAME = "lib%s.a"
3030
CIRCULAR_DEPENDENCIES = True
31-
DIAGNOSTIC_PATTERN = re.compile('((?P<line>\d+):)(\d+:)? (?P<severity>warning|error): (?P<message>.+)')
31+
DIAGNOSTIC_PATTERN = re.compile('((?P<file>[^:]+):(?P<line>\d+):)(\d+:)? (?P<severity>warning|error): (?P<message>.+)')
3232

3333
def __init__(self, target, options=None, notify=None, macros=None, silent=False, tool_path="", extra_verbose=False):
3434
mbedToolchain.__init__(self, target, options, notify, macros, silent, extra_verbose=extra_verbose)
@@ -138,27 +138,16 @@ def parse_output(self, output):
138138
)
139139
continue
140140

141-
# Each line should start with the file information: "filepath: ..."
142-
# i should point past the file path ^
143-
# avoid the first column in Windows (C:\)
144-
i = line.find(':', 2)
145-
if i == -1: continue
146-
147-
if state == WHERE:
148-
file = line[:i]
149-
message = line[i+1:].strip() + ' '
150-
state = WHAT
151-
152-
elif state == WHAT:
153-
match = GCC.DIAGNOSTIC_PATTERN.match(line[i+1:])
154-
if match is None:
155-
state = WHERE
156-
continue
157141

142+
match = GCC.DIAGNOSTIC_PATTERN.match(line)
143+
if match is not None:
158144
self.cc_info(
159-
match.group('severity'),
160-
file, match.group('line'),
161-
message + match.group('message')
145+
match.group('severity').lower(),
146+
match.group('file'),
147+
match.group('line'),
148+
match.group('message'),
149+
target_name=self.target.name,
150+
toolchain_name=self.name
162151
)
163152

164153
def get_dep_option(self, object):

0 commit comments

Comments
 (0)