mirror of https://github.com/ARMmbed/mbed-os.git
Python2+3: mbed test --compile
parent
c93a2bfa4c
commit
1dd39fbe80
|
@ -18,6 +18,7 @@ limitations under the License.
|
|||
|
||||
TEST BUILD & RUN
|
||||
"""
|
||||
from __future__ import print_function, division, absolute_import
|
||||
import sys
|
||||
import os
|
||||
import json
|
||||
|
@ -36,8 +37,8 @@ from tools.build_api import merge_build_data
|
|||
from tools.targets import TARGET_MAP
|
||||
from tools.utils import mkdir, ToolException, NotSupportedException, args_error
|
||||
from tools.test_exporters import ReportExporter, ResultExporterType
|
||||
from utils import argparse_filestring_type, argparse_lowercase_type, argparse_many
|
||||
from utils import argparse_dir_not_parent
|
||||
from tools.utils import argparse_filestring_type, argparse_lowercase_type, argparse_many
|
||||
from tools.utils import argparse_dir_not_parent
|
||||
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS, TOOLCHAIN_CLASSES
|
||||
from tools.settings import CLI_COLOR_MAP
|
||||
|
||||
|
@ -164,7 +165,8 @@ if __name__ == '__main__':
|
|||
if fnmatch.fnmatch(testname, name):
|
||||
tests[testname] = test
|
||||
else:
|
||||
print "[Warning] Test with name '%s' was not found in the available tests" % (name)
|
||||
print("[Warning] Test with name '%s' was not found in the "
|
||||
"available tests" % (name))
|
||||
else:
|
||||
tests = all_tests
|
||||
|
||||
|
@ -211,18 +213,18 @@ if __name__ == '__main__':
|
|||
build_profile=profile)
|
||||
|
||||
library_build_success = True
|
||||
except ToolException, e:
|
||||
except ToolException as e:
|
||||
# ToolException output is handled by the build log
|
||||
pass
|
||||
except NotSupportedException, e:
|
||||
except NotSupportedException as e:
|
||||
# NotSupportedException is handled by the build log
|
||||
pass
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
# Some other exception occurred, print the error message
|
||||
print e
|
||||
print(e)
|
||||
|
||||
if not library_build_success:
|
||||
print "Failed to build library"
|
||||
print("Failed to build library")
|
||||
else:
|
||||
# Build all the tests
|
||||
|
||||
|
@ -252,9 +254,9 @@ if __name__ == '__main__':
|
|||
try:
|
||||
with open(options.test_spec, 'w') as f:
|
||||
f.write(json.dumps(test_spec_data, indent=2))
|
||||
except IOError, e:
|
||||
print "[ERROR] Error writing test spec to file"
|
||||
print e
|
||||
except IOError as e:
|
||||
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:
|
||||
|
@ -264,7 +266,7 @@ if __name__ == '__main__':
|
|||
# Print memory map summary on screen
|
||||
if build_report:
|
||||
print
|
||||
print print_build_memory_usage(build_report)
|
||||
print(print_build_memory_usage(build_report))
|
||||
|
||||
print_report_exporter = ReportExporter(ResultExporterType.PRINT, package="build")
|
||||
status = print_report_exporter.report(build_report)
|
||||
|
@ -276,13 +278,13 @@ if __name__ == '__main__':
|
|||
else:
|
||||
sys.exit(1)
|
||||
|
||||
except KeyboardInterrupt, e:
|
||||
print "\n[CTRL+c] exit"
|
||||
except ConfigException, e:
|
||||
except KeyboardInterrupt as e:
|
||||
print("\n[CTRL+c] exit")
|
||||
except ConfigException as e:
|
||||
# Catching ConfigException here to prevent a traceback
|
||||
print "[ERROR] %s" % str(e)
|
||||
except Exception,e:
|
||||
print("[ERROR] %s" % str(e))
|
||||
except Exception as e:
|
||||
import traceback
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
print "[ERROR] %s" % str(e)
|
||||
print("[ERROR] %s" % str(e))
|
||||
sys.exit(1)
|
||||
|
|
|
@ -29,6 +29,7 @@ import argparse
|
|||
import datetime
|
||||
import threading
|
||||
import ctypes
|
||||
import functools
|
||||
from colorama import Fore, Back, Style
|
||||
from prettytable import PrettyTable
|
||||
from copy import copy
|
||||
|
@ -52,7 +53,7 @@ from tools.utils import ToolException
|
|||
from tools.utils import NotSupportedException
|
||||
from tools.utils import construct_enum
|
||||
from tools.memap import MemapParser
|
||||
from tools.targets import TARGET_MAP
|
||||
from tools.targets import TARGET_MAP, Target
|
||||
import tools.test_configs as TestConfig
|
||||
from tools.test_db import BaseDBAccess
|
||||
from tools.build_api import build_project, build_mbed_libs, build_lib
|
||||
|
@ -2216,7 +2217,7 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
|
|||
execution_directory = "."
|
||||
base_path = norm_relative_path(build_path, execution_directory)
|
||||
|
||||
target_name = target if isinstance(target, str) else target.name
|
||||
target_name = target.name if isinstance(target, Target) else target
|
||||
cfg, _, _ = get_config(base_source_paths, target_name, toolchain_name)
|
||||
|
||||
baud_rate = 9600
|
||||
|
|
|
@ -795,7 +795,7 @@ class mbedToolchain:
|
|||
|
||||
def copy_files(self, files_paths, trg_path, resources=None, rel_path=None):
|
||||
# Handle a single file
|
||||
if isinstance(files_paths, list):
|
||||
if not isinstance(files_paths, list):
|
||||
files_paths = [files_paths]
|
||||
|
||||
for source in files_paths:
|
||||
|
@ -1291,7 +1291,6 @@ class mbedToolchain:
|
|||
self.config_file = None # this means "config file not present"
|
||||
changed = True
|
||||
elif crt_data != prev_data: # different content of config file
|
||||
print("changed!")
|
||||
with open(self.config_file, "w") as f:
|
||||
f.write(crt_data)
|
||||
changed = True
|
||||
|
|
Loading…
Reference in New Issue