|
18 | 18 |
|
19 | 19 | TEST BUILD & RUN
|
20 | 20 | """
|
| 21 | +from __future__ import print_function, division, absolute_import |
21 | 22 | import sys
|
22 | 23 | import os
|
23 | 24 | import json
|
|
36 | 37 | from tools.targets import TARGET_MAP
|
37 | 38 | from tools.utils import mkdir, ToolException, NotSupportedException, args_error
|
38 | 39 | from tools.test_exporters import ReportExporter, ResultExporterType
|
39 |
| -from utils import argparse_filestring_type, argparse_lowercase_type, argparse_many |
40 |
| -from utils import argparse_dir_not_parent |
| 40 | +from tools.utils import argparse_filestring_type, argparse_lowercase_type, argparse_many |
| 41 | +from tools.utils import argparse_dir_not_parent |
41 | 42 | from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS, TOOLCHAIN_CLASSES
|
42 | 43 | from tools.settings import CLI_COLOR_MAP
|
43 | 44 |
|
|
164 | 165 | if fnmatch.fnmatch(testname, name):
|
165 | 166 | tests[testname] = test
|
166 | 167 | else:
|
167 |
| - print "[Warning] Test with name '%s' was not found in the available tests" % (name) |
| 168 | + print("[Warning] Test with name '%s' was not found in the " |
| 169 | + "available tests" % (name)) |
168 | 170 | else:
|
169 | 171 | tests = all_tests
|
170 | 172 |
|
|
211 | 213 | build_profile=profile)
|
212 | 214 |
|
213 | 215 | library_build_success = True
|
214 |
| - except ToolException, e: |
| 216 | + except ToolException as e: |
215 | 217 | # ToolException output is handled by the build log
|
216 | 218 | pass
|
217 |
| - except NotSupportedException, e: |
| 219 | + except NotSupportedException as e: |
218 | 220 | # NotSupportedException is handled by the build log
|
219 | 221 | pass
|
220 |
| - except Exception, e: |
| 222 | + except Exception as e: |
221 | 223 | # Some other exception occurred, print the error message
|
222 |
| - print e |
| 224 | + print(e) |
223 | 225 |
|
224 | 226 | if not library_build_success:
|
225 |
| - print "Failed to build library" |
| 227 | + print("Failed to build library") |
226 | 228 | else:
|
227 | 229 | # Build all the tests
|
228 | 230 |
|
|
252 | 254 | try:
|
253 | 255 | with open(options.test_spec, 'w') as f:
|
254 | 256 | f.write(json.dumps(test_spec_data, indent=2))
|
255 |
| - except IOError, e: |
256 |
| - print "[ERROR] Error writing test spec to file" |
257 |
| - print e |
| 257 | + except IOError as e: |
| 258 | + print("[ERROR] Error writing test spec to file") |
| 259 | + print(e) |
258 | 260 |
|
259 | 261 | # If a path to a JUnit build report spec is provided, write it to a file
|
260 | 262 | if options.build_report_junit:
|
|
264 | 266 | # Print memory map summary on screen
|
265 | 267 | if build_report:
|
266 | 268 | print
|
267 |
| - print print_build_memory_usage(build_report) |
| 269 | + print(print_build_memory_usage(build_report)) |
268 | 270 |
|
269 | 271 | print_report_exporter = ReportExporter(ResultExporterType.PRINT, package="build")
|
270 | 272 | status = print_report_exporter.report(build_report)
|
|
276 | 278 | else:
|
277 | 279 | sys.exit(1)
|
278 | 280 |
|
279 |
| - except KeyboardInterrupt, e: |
280 |
| - print "\n[CTRL+c] exit" |
281 |
| - except ConfigException, e: |
| 281 | + except KeyboardInterrupt as e: |
| 282 | + print("\n[CTRL+c] exit") |
| 283 | + except ConfigException as e: |
282 | 284 | # Catching ConfigException here to prevent a traceback
|
283 |
| - print "[ERROR] %s" % str(e) |
284 |
| - except Exception,e: |
| 285 | + print("[ERROR] %s" % str(e)) |
| 286 | + except Exception as e: |
285 | 287 | import traceback
|
286 | 288 | traceback.print_exc(file=sys.stdout)
|
287 |
| - print "[ERROR] %s" % str(e) |
| 289 | + print("[ERROR] %s" % str(e)) |
288 | 290 | sys.exit(1)
|
0 commit comments