Merge pull request #89 from bridadan/test-build-reporting

Test build reporting
Sam Grove 2016-05-24 08:18:25 +08:00
commit 42624d06af
3 changed files with 31 additions and 5 deletions

View File

@ -109,8 +109,10 @@ def build_project(src_path, build_path, target, toolchain_name,
if report != None:
start = time()
id_name = project_id.upper()
description = project_description
# If project_id is specified, use that over the default name
id_name = project_id.upper() if project_id else name.upper()
description = project_description if project_description else name
vendor_label = target.extra_labels[0]
cur_result = None
prep_report(report, target.name, toolchain_name, id_name)
@ -190,7 +192,8 @@ def build_project(src_path, build_path, target, toolchain_name,
def build_library(src_paths, build_path, target, toolchain_name,
dependencies_paths=None, options=None, name=None, clean=False, archive=True,
notify=None, verbose=False, macros=None, inc_dirs=None, inc_dirs_ext=None,
jobs=1, silent=False, report=None, properties=None, extra_verbose=False):
jobs=1, silent=False, report=None, properties=None, extra_verbose=False,
project_id=None):
""" src_path: the path of the source directory
build_path: the path of the build directory
target: ['LPC1768', 'LPC11U24', 'LPC2368']
@ -213,7 +216,9 @@ def build_library(src_paths, build_path, target, toolchain_name,
if report != None:
start = time()
id_name = name.upper()
# If project_id is specified, use that over the default name
id_name = project_id.upper() if project_id else name.upper()
description = name
vendor_label = target.extra_labels[0]
cur_result = None

View File

@ -30,6 +30,7 @@ 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.test_exporters import ReportExporter, ResultExporterType
if __name__ == '__main__':
try:
@ -66,6 +67,9 @@ if __name__ == '__main__':
parser.add_option("--test-spec", dest="test_spec",
default=None, help="Destination path for a test spec file that can be used by the Greentea automated test tool")
parser.add_option("--build-report-junit", dest="build_report_junit",
default=None, help="Destination path for a build report in the JUnit xml format")
parser.add_option("-v", "--verbose",
action="store_true",
dest="verbose",
@ -118,16 +122,25 @@ if __name__ == '__main__':
target = TARGET_MAP[options.mcu]
build_report = {}
build_properties = {}
# Build sources
lib_build_res = build_library(base_source_paths, options.build_dir, target, options.tool,
options=options.options,
jobs=options.jobs,
clean=options.clean,
report=build_report,
properties=build_properties,
name="mbed-os",
archive=False)
# Build all the tests
test_build = build_tests(tests, [options.build_dir], options.build_dir, target, options.tool,
options=options.options,
clean=options.clean,
report=build_report,
properties=build_properties,
jobs=options.jobs)
# If a path to a test spec is provided, write it to a file
@ -147,6 +160,10 @@ if __name__ == '__main__':
print "[ERROR] Error writing test spec to file"
print e
# If a path to a JUnit build report spec is provided, write it to a file
if options.build_report_junit:
report_exporter = ReportExporter(ResultExporterType.JUNIT)
report_exporter.report_to_file(build_report, options.build_report_junit, test_suite_properties=build_properties)
sys.exit()
except KeyboardInterrupt, e:

View File

@ -17,7 +17,8 @@ limitations under the License.
Author: Przemyslaw Wirkus <Przemyslaw.wirkus@arm.com>
"""
from tools.utils import construct_enum
from tools.utils import construct_enum, mkdir
import os
ResultExporterType = construct_enum(HTML='Html_Exporter',
@ -97,6 +98,9 @@ class ReportExporter():
def write_to_file(self, report, file_name):
if report is not None:
dirname = os.path.dirname(file_name)
if dirname:
mkdir(dirname)
with open(file_name, 'w') as f:
f.write(report)