[Exporter tests] Implement filtering of targets and examples.

pull/3206/head
Sarah Marsh 2016-11-04 15:48:02 -05:00
parent 811e2b55e6
commit 4e2d3c42dd
2 changed files with 38 additions and 31 deletions

View File

@ -32,7 +32,8 @@ def main():
parser.add_argument("-c", dest="config", default="examples.json")
parser.add_argument("-e", "--example",
help=("filter the examples used in the script"),
type=argparse_many()
type=argparse_many(lambda x: x),
default = EXAMPLES.keys())
subparsers = parser.add_subparsers()
import_cmd = subparsers.add_parser("import")
import_cmd.set_defaults(fn=do_import)
@ -55,7 +56,8 @@ def main():
metavar="MCU",
type=argparse_many(
argparse_force_uppercase_type(
official_target_names, "MCU")))
official_target_names, "MCU")),
default=official_target_names)
export_cmd = subparsers.add_parser("export")
export_cmd.set_defaults(fn=do_export),
export_cmd.add_argument(
@ -68,7 +70,8 @@ def main():
metavar="MCU",
type=argparse_many(
argparse_force_uppercase_type(
official_target_names, "MCU")))
official_target_names, "MCU")),
default=official_target_names)
args = parser.parse_args()
config = json.load(open(os.path.join(os.path.dirname(__file__),
args.config)))
@ -78,7 +81,7 @@ def main():
def do_export(args, config):
"""Do export and build step"""
results = {}
results = lib.export_repos(config, args.ide)
results = lib.export_repos(config, args.ide, args.mcu, args.example)
lib.print_summary(results, export=True)
failures = lib.get_num_failures(results, export=True)
@ -107,7 +110,7 @@ def do_deploy(_, config):
def do_compile(args, config):
"""Do the compile step"""
results = {}
results = lib.compile_repos(config, args.toolchains)
results = lib.compile_repos(config, args.toolchains, args.mcu, args.example)
lib.print_summary(results)
failures = lib.get_num_failures(results)

View File

@ -228,8 +228,7 @@ def get_num_failures(results, export=False):
return num_failures
def export_repos(config, ides):
def export_repos(config, ides, targets, examples):
"""Exports and builds combinations of example programs, targets and IDEs.
The results are returned in a [key: value] dictionary format:
@ -239,8 +238,7 @@ def export_repos(config, ides):
where pass_status = The overall pass status for the export of the full
set of example programs comprising the example suite.
(IE they must build and export)
True if all examples pass, false otherwise
IE they must build and export) True if all examples pass, false otherwise
successes = list of examples that exported and built (if possible)
If the exporter has no build functionality, then it is a pass
if exported
@ -257,6 +255,9 @@ def export_repos(config, ides):
results = {}
print("\nExporting example repos....\n")
for example in config['examples']:
if example['name'] not in examples:
continue
export_failures = []
build_failures = []
build_skips = []
@ -271,7 +272,7 @@ def export_repos(config, ides):
# list of valid combinations to work through
for target, ide in target_cross_ide(ides,
example['features'],
example['targets']):
example['targets'] or targets):
example_name = "{} {} {}".format(example_project_name, target,
ide)
def status(message):
@ -311,7 +312,7 @@ def export_repos(config, ides):
return results
def compile_repos(config, toolchains):
def compile_repos(config, toolchains, targets, examples):
"""Compiles combinations of example programs, targets and compile chains.
The results are returned in a [key: value] dictionary format:
@ -335,6 +336,8 @@ def compile_repos(config, toolchains):
results = {}
print("\nCompiling example repos....\n")
for example in config['examples']:
if example['name'] not in examples:
continue
failures = []
successes = []
compiled = True
@ -350,7 +353,8 @@ def compile_repos(config, toolchains):
# Check that the target, toolchain and features combinations are valid and return a
# list of valid combinations to work through
for target, toolchain in target_cross_toolchain(toolchains,
example['features'], example['targets']):
example['features'],
example['targets'] or targets):
proc = subprocess.Popen(["mbed-cli", "compile", "-t", toolchain,
"-m", target, "--silent"])
proc.wait()
@ -372,7 +376,7 @@ def compile_repos(config, toolchains):
return results
def update_mbedos_version(config, tag):
def update_mbedos_version(config, tag, example):
""" For each example repo identified in the config json object, update the version of
mbed-os to that specified by the supplied GitHub tag. This function assumes that each
example repo has already been cloned.