Skip to content

Commit 4e2d3c4

Browse files
committed
[Exporter tests] Implement filtering of targets and examples.
1 parent 811e2b5 commit 4e2d3c4

File tree

2 files changed

+41
-34
lines changed

2 files changed

+41
-34
lines changed

tools/test/examples/examples.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def main():
3232
parser.add_argument("-c", dest="config", default="examples.json")
3333
parser.add_argument("-e", "--example",
3434
help=("filter the examples used in the script"),
35-
type=argparse_many()
35+
type=argparse_many(lambda x: x),
36+
default = EXAMPLES.keys())
3637
subparsers = parser.add_subparsers()
3738
import_cmd = subparsers.add_parser("import")
3839
import_cmd.set_defaults(fn=do_import)
@@ -55,7 +56,8 @@ def main():
5556
metavar="MCU",
5657
type=argparse_many(
5758
argparse_force_uppercase_type(
58-
official_target_names, "MCU")))
59+
official_target_names, "MCU")),
60+
default=official_target_names)
5961
export_cmd = subparsers.add_parser("export")
6062
export_cmd.set_defaults(fn=do_export),
6163
export_cmd.add_argument(
@@ -68,7 +70,8 @@ def main():
6870
metavar="MCU",
6971
type=argparse_many(
7072
argparse_force_uppercase_type(
71-
official_target_names, "MCU")))
73+
official_target_names, "MCU")),
74+
default=official_target_names)
7275
args = parser.parse_args()
7376
config = json.load(open(os.path.join(os.path.dirname(__file__),
7477
args.config)))
@@ -78,7 +81,7 @@ def main():
7881
def do_export(args, config):
7982
"""Do export and build step"""
8083
results = {}
81-
results = lib.export_repos(config, args.ide)
84+
results = lib.export_repos(config, args.ide, args.mcu, args.example)
8285

8386
lib.print_summary(results, export=True)
8487
failures = lib.get_num_failures(results, export=True)
@@ -107,7 +110,7 @@ def do_deploy(_, config):
107110
def do_compile(args, config):
108111
"""Do the compile step"""
109112
results = {}
110-
results = lib.compile_repos(config, args.toolchains)
113+
results = lib.compile_repos(config, args.toolchains, args.mcu, args.example)
111114

112115
lib.print_summary(results)
113116
failures = lib.get_num_failures(results)

tools/test/examples/examples_lib.py

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -228,35 +228,36 @@ def get_num_failures(results, export=False):
228228

229229
return num_failures
230230

231-
232-
def export_repos(config, ides):
231+
def export_repos(config, ides, targets, examples):
233232
"""Exports and builds combinations of example programs, targets and IDEs.
234233
235-
The results are returned in a [key: value] dictionary format:
236-
Where key = The example name from the json config file
237-
value = a list containing: pass_status, successes, export failures, build_failures,
238-
and build_skips
239-
240-
where pass_status = The overall pass status for the export of the full
241-
set of example programs comprising the example suite.
242-
(IE they must build and export)
243-
True if all examples pass, false otherwise
244-
successes = list of examples that exported and built (if possible)
245-
If the exporter has no build functionality, then it is a pass
246-
if exported
247-
export_failures = list of examples that failed to export.
248-
build_failures = list of examples that failed to build
249-
build_skips = list of examples that cannot build
250-
251-
Both successes and failures contain the example name, target and IDE
252-
253-
Args:
254-
config - the json object imported from the file.
255-
ides - List of IDES to export to
256-
"""
234+
The results are returned in a [key: value] dictionary format:
235+
Where key = The example name from the json config file
236+
value = a list containing: pass_status, successes, export failures, build_failures,
237+
and build_skips
238+
239+
where pass_status = The overall pass status for the export of the full
240+
set of example programs comprising the example suite.
241+
IE they must build and export) True if all examples pass, false otherwise
242+
successes = list of examples that exported and built (if possible)
243+
If the exporter has no build functionality, then it is a pass
244+
if exported
245+
export_failures = list of examples that failed to export.
246+
build_failures = list of examples that failed to build
247+
build_skips = list of examples that cannot build
248+
249+
Both successes and failures contain the example name, target and IDE
250+
251+
Args:
252+
config - the json object imported from the file.
253+
ides - List of IDES to export to
254+
"""
257255
results = {}
258256
print("\nExporting example repos....\n")
259257
for example in config['examples']:
258+
if example['name'] not in examples:
259+
continue
260+
260261
export_failures = []
261262
build_failures = []
262263
build_skips = []
@@ -271,7 +272,7 @@ def export_repos(config, ides):
271272
# list of valid combinations to work through
272273
for target, ide in target_cross_ide(ides,
273274
example['features'],
274-
example['targets']):
275+
example['targets'] or targets):
275276
example_name = "{} {} {}".format(example_project_name, target,
276277
ide)
277278
def status(message):
@@ -311,7 +312,7 @@ def status(message):
311312
return results
312313

313314

314-
def compile_repos(config, toolchains):
315+
def compile_repos(config, toolchains, targets, examples):
315316
"""Compiles combinations of example programs, targets and compile chains.
316317
317318
The results are returned in a [key: value] dictionary format:
@@ -334,7 +335,9 @@ def compile_repos(config, toolchains):
334335
"""
335336
results = {}
336337
print("\nCompiling example repos....\n")
337-
for example in config['examples']:
338+
for example in config['examples']:
339+
if example['name'] not in examples:
340+
continue
338341
failures = []
339342
successes = []
340343
compiled = True
@@ -350,7 +353,8 @@ def compile_repos(config, toolchains):
350353
# Check that the target, toolchain and features combinations are valid and return a
351354
# list of valid combinations to work through
352355
for target, toolchain in target_cross_toolchain(toolchains,
353-
example['features'], example['targets']):
356+
example['features'],
357+
example['targets'] or targets):
354358
proc = subprocess.Popen(["mbed-cli", "compile", "-t", toolchain,
355359
"-m", target, "--silent"])
356360
proc.wait()
@@ -372,7 +376,7 @@ def compile_repos(config, toolchains):
372376
return results
373377

374378

375-
def update_mbedos_version(config, tag):
379+
def update_mbedos_version(config, tag, example):
376380
""" For each example repo identified in the config json object, update the version of
377381
mbed-os to that specified by the supplied GitHub tag. This function assumes that each
378382
example repo has already been cloned.

0 commit comments

Comments
 (0)