|
30 | 30 | from tools.build_api import build_project, build_library
|
31 | 31 | from tools.targets import TARGET_MAP
|
32 | 32 | from tools.utils import mkdir
|
| 33 | +from tools.test_exporters import ReportExporter, ResultExporterType |
33 | 34 |
|
34 | 35 | if __name__ == '__main__':
|
35 | 36 | try:
|
|
66 | 67 | parser.add_option("--test-spec", dest="test_spec",
|
67 | 68 | default=None, help="Destination path for a test spec file that can be used by the Greentea automated test tool")
|
68 | 69 |
|
| 70 | + parser.add_option("--build-report-junit", dest="build_report_junit", |
| 71 | + default=None, help="Destination path for a build report in the JUnit xml format") |
| 72 | + |
69 | 73 | parser.add_option("-v", "--verbose",
|
70 | 74 | action="store_true",
|
71 | 75 | dest="verbose",
|
|
118 | 122 |
|
119 | 123 | target = TARGET_MAP[options.mcu]
|
120 | 124 |
|
| 125 | + build_report = {} |
| 126 | + build_properties = {} |
| 127 | + |
| 128 | + # Build sources |
121 | 129 | lib_build_res = build_library(base_source_paths, options.build_dir, target, options.tool,
|
122 | 130 | options=options.options,
|
123 | 131 | jobs=options.jobs,
|
124 | 132 | clean=options.clean,
|
| 133 | + report=build_report, |
| 134 | + properties=build_properties, |
| 135 | + name="mbed-os", |
125 | 136 | archive=False)
|
126 | 137 |
|
127 | 138 | # Build all the tests
|
128 | 139 | test_build = build_tests(tests, [options.build_dir], options.build_dir, target, options.tool,
|
129 | 140 | options=options.options,
|
130 | 141 | clean=options.clean,
|
| 142 | + report=build_report, |
| 143 | + properties=build_properties, |
131 | 144 | jobs=options.jobs)
|
132 | 145 |
|
133 | 146 | # If a path to a test spec is provided, write it to a file
|
|
147 | 160 | print "[ERROR] Error writing test spec to file"
|
148 | 161 | print e
|
149 | 162 |
|
| 163 | + # If a path to a JUnit build report spec is provided, write it to a file |
| 164 | + if options.build_report_junit: |
| 165 | + report_exporter = ReportExporter(ResultExporterType.JUNIT) |
| 166 | + report_exporter.report_to_file(build_report, options.build_report_junit, test_suite_properties=build_properties) |
150 | 167 | sys.exit()
|
151 | 168 |
|
152 | 169 | except KeyboardInterrupt, e:
|
|
0 commit comments