From 72dbc52715fffb6650b482205949966849009c9d Mon Sep 17 00:00:00 2001 From: Cruz Monrreal II Date: Fri, 25 Jan 2019 14:08:59 -0600 Subject: [PATCH 01/10] Added flag to run_cmd Popen invocation to do default decoding --- tools/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/utils.py b/tools/utils.py index fb8869c29cc..ad5db06fdf4 100644 --- a/tools/utils.py +++ b/tools/utils.py @@ -104,7 +104,8 @@ def run_cmd(command, work_dir=None, chroot=None, redirect=False): try: process = Popen(command, stdout=PIPE, - stderr=STDOUT if redirect else PIPE, cwd=work_dir) + stderr=STDOUT if redirect else PIPE, cwd=work_dir, + universal_newlines=True) _stdout, _stderr = process.communicate() except OSError: print("[OS ERROR] Command: "+(' '.join(command))) From d9add3447d65a2c24fde0b538c23c54f1699a424 Mon Sep 17 00:00:00 2001 From: Cruz Monrreal II Date: Fri, 25 Jan 2019 11:37:56 -0600 Subject: [PATCH 02/10] Added None check for min in config tools --- tools/config/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/config/__init__.py b/tools/config/__init__.py index 747692eb359..7e456de706d 100644 --- a/tools/config/__init__.py +++ b/tools/config/__init__.py @@ -1204,7 +1204,8 @@ def validate_config(self): min = int(str(min), 0) if min is not None else None max = int(str(max), 0) if max is not None else None - if (value < min or (value > max if max is not None else False)): + if ((value < min if min is not None else False) or + (value > max if max is not None else False)): err_msg += "\nInvalid config range for %s, is not in the required range: [%s:%s]"\ % (param, min if min is not None else "-inf", From cc3114113d12a6d0d608aa9dc4ded84c6f7f572f Mon Sep 17 00:00:00 2001 From: Cruz Monrreal II Date: Fri, 25 Jan 2019 11:28:26 -0600 Subject: [PATCH 03/10] In Py3.7, a reinit of a mock variable was needed. It seems that initializing mock variables in an object isn't enough --- tools/test/build_api/build_api_test.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/test/build_api/build_api_test.py b/tools/test/build_api/build_api_test.py index a50118bea5c..2fcfc947b8c 100644 --- a/tools/test/build_api/build_api_test.py +++ b/tools/test/build_api/build_api_test.py @@ -141,6 +141,7 @@ def test_build_project_app_config(self, mock_prepare_toolchain, mock_exists, _, lib_config_data=None, ) mock_prepare_toolchain().config.deliver_into.return_value = (None, None) + mock_prepare_toolchain().config.name = None build_project(self.src_paths, self.build_path, self.target, self.toolchain_name, app_config=app_config, notify=notify) @@ -175,6 +176,7 @@ def test_build_project_no_app_config(self, mock_prepare_toolchain, mock_exists, lib_config_data=None, ) mock_prepare_toolchain().config.deliver_into.return_value = (None, None) + mock_prepare_toolchain().config.name = None build_project(self.src_paths, self.build_path, self.target, self.toolchain_name, notify=notify) From 149d280e7a0bb8d50f2def942892c80ad504ab2e Mon Sep 17 00:00:00 2001 From: Cruz Monrreal II Date: Thu, 24 Jan 2019 00:14:51 -0600 Subject: [PATCH 04/10] Added encoding to version check for Py3 compat --- tools/toolchains/arm.py | 2 +- tools/toolchains/gcc.py | 2 +- tools/toolchains/iar.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/toolchains/arm.py b/tools/toolchains/arm.py index 09f76a8fa49..b609784e74a 100644 --- a/tools/toolchains/arm.py +++ b/tools/toolchains/arm.py @@ -102,7 +102,7 @@ def version_check(self): stdout, _, retcode = run_cmd([self.cc[0], "--vsn"], redirect=True) msg = None min_ver, max_ver = self.ARMCC_RANGE - match = self.ARMCC_VERSION_RE.search(stdout) + match = self.ARMCC_VERSION_RE.search(stdout.encode("utf-8")) found_version = LooseVersion(match.group(1).decode("utf-8")) if match else None min_ver, max_ver = self.ARMCC_RANGE if found_version and (found_version < min_ver or found_version >= max_ver): diff --git a/tools/toolchains/gcc.py b/tools/toolchains/gcc.py index af3c5ca6aa3..d2fd8cb2583 100644 --- a/tools/toolchains/gcc.py +++ b/tools/toolchains/gcc.py @@ -133,7 +133,7 @@ def __init__(self, target, notify=None, macros=None, build_profile=None, def version_check(self): stdout, _, retcode = run_cmd([self.cc[0], "--version"], redirect=True) msg = None - match = self.GCC_VERSION_RE.search(stdout) + match = self.GCC_VERSION_RE.search(stdout.encode("utf-8")) found_version = LooseVersion(match.group(0).decode('utf-8')) if match else None min_ver, max_ver = self.GCC_RANGE if found_version and (found_version < min_ver or found_version >= max_ver): diff --git a/tools/toolchains/iar.py b/tools/toolchains/iar.py index c94d5f089d4..37c085295b2 100644 --- a/tools/toolchains/iar.py +++ b/tools/toolchains/iar.py @@ -99,7 +99,7 @@ def __init__(self, target, notify=None, macros=None, build_profile=None, def version_check(self): stdout, _, retcode = run_cmd([self.cc[0], "--version"], redirect=True) msg = None - match = self.IAR_VERSION_RE.search(stdout) + match = self.IAR_VERSION_RE.search(stdout.encode("utf-8")) found_version = match.group(1).decode("utf-8") if match else None if found_version and LooseVersion(found_version) != self.IAR_VERSION: msg = "Compiler version mismatch: Have {}; expected {}".format( From 2a9a45d0870c1432dac2ad7cb2b01f530b57f237 Mon Sep 17 00:00:00 2001 From: Cruz Monrreal II Date: Wed, 23 Jan 2019 22:46:43 -0600 Subject: [PATCH 05/10] Increased path for spm include. Py3 tests were not running as a result --- tools/test/spm/test_generate_partition_code.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test/spm/test_generate_partition_code.py b/tools/test/spm/test_generate_partition_code.py index 7726e3a84f1..245dcd6f571 100644 --- a/tools/test/spm/test_generate_partition_code.py +++ b/tools/test/spm/test_generate_partition_code.py @@ -23,7 +23,7 @@ import pytest from jinja2.defaults import DEFAULT_FILTERS -from test_data import * +from tools.test.spm.test_data import * from tools.spm.generate_partition_code import * # Imported again as a module for monkey-patching From 533dcf36ff83836b2a0fea86f20ca22cc81cf458 Mon Sep 17 00:00:00 2001 From: Cruz Monrreal II Date: Wed, 23 Jan 2019 22:21:18 -0600 Subject: [PATCH 06/10] Added universal_newlines flag to Popen in pylint.py --- tools/test/pylint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/test/pylint.py b/tools/test/pylint.py index cae95ca02bd..9fc43ae18bf 100644 --- a/tools/test/pylint.py +++ b/tools/test/pylint.py @@ -26,7 +26,8 @@ def execute_pylint(filename): process = subprocess.Popen( ["pylint", filename], stdout=subprocess.PIPE, - stderr=subprocess.PIPE + stderr=subprocess.PIPE, + universal_newlines=True ) stout, sterr = process.communicate() status = process.poll() From d58245146988a1d8847ba757452f7055f0883788 Mon Sep 17 00:00:00 2001 From: Cruz Monrreal II Date: Mon, 28 Jan 2019 13:02:37 -0600 Subject: [PATCH 07/10] Enabled Py3.{5,6,7} in Travis CI --- .travis.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7ecfcd570cd..5f4a68b9956 100644 --- a/.travis.yml +++ b/.travis.yml @@ -152,13 +152,17 @@ matrix: # Report success since we have overridden default behavior - bash -c "$STATUS" success "Local $NAME testing has passed" -# - <<: *tools-pytest -# env: NAME=tools-py3.5 -# python: 3.5 -# -# - <<: *tools-pytest -# env: NAME=tools-py3.6 -# python: 3.6 + - <<: *tools-pytest + env: NAME=tools-py3.5 + python: 3.5 + + - <<: *tools-pytest + env: NAME=tools-py3.6 + python: 3.6 + + - <<: *tools-pytest + env: NAME=tools-py3.7 + python: 3.7 - env: - NAME=astyle From 861816c20b383366f6062ac6df0301087aeb9c51 Mon Sep 17 00:00:00 2001 From: Cruz Monrreal II Date: Mon, 28 Jan 2019 13:54:28 -0600 Subject: [PATCH 08/10] Enable xenail dist for only Py37 job Other jobs will follow with other PR --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5f4a68b9956..6c2caa9a6c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -163,6 +163,7 @@ matrix: - <<: *tools-pytest env: NAME=tools-py3.7 python: 3.7 + dist: xenial - env: - NAME=astyle From de4b7607a046b9f32d3b6cd475d388fd5e925d16 Mon Sep 17 00:00:00 2001 From: Cruz Monrreal II Date: Mon, 28 Jan 2019 14:01:48 -0600 Subject: [PATCH 09/10] Simplified max/min condition --- tools/config/__init__.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/config/__init__.py b/tools/config/__init__.py index 7e456de706d..f8027c3529a 100644 --- a/tools/config/__init__.py +++ b/tools/config/__init__.py @@ -1204,8 +1204,7 @@ def validate_config(self): min = int(str(min), 0) if min is not None else None max = int(str(max), 0) if max is not None else None - if ((value < min if min is not None else False) or - (value > max if max is not None else False)): + if (min is not None and value < min) or (max is not None and value > max): err_msg += "\nInvalid config range for %s, is not in the required range: [%s:%s]"\ % (param, min if min is not None else "-inf", From b836b340a288205fde43443d086119135c1d454b Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Tue, 29 Jan 2019 14:54:42 -0600 Subject: [PATCH 10/10] Updated spm test runner wish short import variant Co-Authored-By: cmonr --- tools/test/spm/test_generate_partition_code.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test/spm/test_generate_partition_code.py b/tools/test/spm/test_generate_partition_code.py index 245dcd6f571..13abd5e2956 100644 --- a/tools/test/spm/test_generate_partition_code.py +++ b/tools/test/spm/test_generate_partition_code.py @@ -23,7 +23,7 @@ import pytest from jinja2.defaults import DEFAULT_FILTERS -from tools.test.spm.test_data import * +from .test_data import * from tools.spm.generate_partition_code import * # Imported again as a module for monkey-patching