From f1e885f491e8d0f5c6243a7587746f80ab8ab904 Mon Sep 17 00:00:00 2001 From: Qinghao Shi Date: Wed, 9 Sep 2020 18:26:17 +0100 Subject: [PATCH 1/3] TEST: add a cmake option in example testing script --- tools/test/examples/examples.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/test/examples/examples.py b/tools/test/examples/examples.py index 586a33f87b..5e2162111f 100644 --- a/tools/test/examples/examples.py +++ b/tools/test/examples/examples.py @@ -93,6 +93,7 @@ def parse_args(): default=0, help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)") + compile_cmd.add_argument("--cmake", action="store_true", dest="cmake", default=False, help="Use Cmake to build example") compile_cmd.add_argument("-v", "--verbose", action="store_true", dest="verbose", From e9e53e4ba39407fde306309ed538c48b343a6a0c Mon Sep 17 00:00:00 2001 From: Qinghao Shi Date: Wed, 9 Sep 2020 18:38:05 +0100 Subject: [PATCH 2/3] TEST: change to overwrite instead of remove --- tools/test/examples/examples_lib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/test/examples/examples_lib.py b/tools/test/examples/examples_lib.py index 11c0c4e3b2..b37782e8a0 100644 --- a/tools/test/examples/examples_lib.py +++ b/tools/test/examples/examples_lib.py @@ -476,8 +476,8 @@ def symlink_mbedos(config, path, exp_filter): os.chdir(name) logging.info("In folder '%s'" % name) if os.path.exists("mbed-os.lib"): - logging.info("Removing 'mbed-os.lib' in '%s'" % name) - os.remove("mbed-os.lib") + logging.info("Replacing 'mbed-os.lib' with empty file in '%s'" % name) + open("mbed-os.lib", 'w').close() else: logging.warning("No 'mbed-os.lib' found in '%s'" % name) if os.path.exists("mbed-os"): From d86a97b21c04f4da94ca99a700543c04463e2fe3 Mon Sep 17 00:00:00 2001 From: Qinghao Shi Date: Thu, 10 Sep 2020 13:06:39 +0100 Subject: [PATCH 3/3] TEST: update example script update function --- tools/test/examples/README.md | 2 +- tools/test/examples/examples.py | 4 ++-- tools/test/examples/examples_lib.py | 11 +++++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/tools/test/examples/README.md b/tools/test/examples/README.md index 76c35db1bd..9fea81168b 100644 --- a/tools/test/examples/README.md +++ b/tools/test/examples/README.md @@ -16,7 +16,7 @@ The scripts in this folder are used for testing `mbed-os` official examples. It * **deploy** - if the example directory exists as provided by the .json configuration file, pulls in the examples dependencies by using `mbed-cli deploy`. -* **update** - for each example repo identified in the config .json object, updates the version of `mbed-os` to that specified by the supplied GitHub tag. This function assumes that each example repo has already been cloned. +* **update** - for each example repo identified in the config .json object, updates the version of example to that specified by the supplied GitHub tag. This function assumes that each example repo has already been cloned. * **compile** - compiles combinations of example programs, targets and compile chains. diff --git a/tools/test/examples/examples.py b/tools/test/examples/examples.py index 5e2162111f..a590915a1b 100644 --- a/tools/test/examples/examples.py +++ b/tools/test/examples/examples.py @@ -165,8 +165,8 @@ def do_compile(args, config, examples): return failures def do_update(args, config, examples): - """ Test update the mbed-os to the version specified by the tag """ - return lib.update_mbedos_version(config, args.TAG, examples) + """ Test update the example to the version specified by the tag """ + return lib.update_example_version(config, args.TAG, examples) def do_list(_, config, examples): """List the examples in the config file""" diff --git a/tools/test/examples/examples_lib.py b/tools/test/examples/examples_lib.py index b37782e8a0..b49964d4a9 100644 --- a/tools/test/examples/examples_lib.py +++ b/tools/test/examples/examples_lib.py @@ -438,9 +438,9 @@ def compile_repos(config, toolchains, targets, profiles, verbose, exp_filter, jo return results -def update_mbedos_version(config, tag, exp_filter): +def update_example_version(config, tag, exp_filter): """ 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 to that specified by the supplied GitHub tag. This function assumes that each example repo has already been cloned. Args: @@ -448,15 +448,14 @@ def update_mbedos_version(config, tag, exp_filter): tag - GitHub tag corresponding to a version of mbed-os to upgrade to. """ - print("\nUpdating mbed-os in examples to version '%s'\n" % tag) + print("\nUpdating example to version(branch) '%s'\n" % tag) for example in config['examples']: if example['name'] not in exp_filter: continue for name in get_sub_examples_list(example): - update_dir = name + "/mbed-os" - os.chdir(update_dir) + os.chdir(name) logging.info("In folder '%s'" % name) - cmd = "mbed-cli update %s --clean" %tag + cmd = "git checkout -B %s origin/%s" %(tag, tag) logging.info("Executing command '%s'..." % cmd) result = subprocess.call(cmd, shell=True) os.chdir(CWD)