From 51718ed1d1414b17562107394e4f3b999268edfd Mon Sep 17 00:00:00 2001 From: Sean Yen Date: Fri, 8 Feb 2019 22:22:45 -0800 Subject: [PATCH 1/3] Use threading + add Azure test pipeline. --- azure-pipelines.yml | 27 +++++++++++++++++++++++++++ src/catkin_pkg/packages.py | 12 +++++++++++- test/test_packages.py | 2 +- 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..63253dfd --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,27 @@ +jobs: +- job: 'Build' + pool: + vmImage: 'vs2017-win2016' + strategy: + matrix: + Python27: + python.version: '2.7' + Python35: + python.version: '3.5' + Python36: + python.version: '3.6' + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: '$(python.version)' + architecture: 'x64' + - script: | + python -m pip install nose coverage argparse python-dateutil docutils pyparsing + python -m pip install flake8 flake8-blind-except flake8-builtins flake8-class-newline flake8-comprehensions flake8-deprecated flake8-docstrings flake8-import-order flake8-quotes + python -m pip install mock + - script: | + python -m nose --with-xunit + - task: PublishTestResults@2 + condition: succeededOrFailed() + inputs: + testResultsFiles: '**/*.xml' diff --git a/src/catkin_pkg/packages.py b/src/catkin_pkg/packages.py index 9779f6fd..efaacdef 100644 --- a/src/catkin_pkg/packages.py +++ b/src/catkin_pkg/packages.py @@ -32,8 +32,18 @@ """Library to find packages in the filesystem.""" -import multiprocessing import os +if os.name == 'nt': + # https://docs.python.org/2/library/multiprocessing.html#windows + # + # On Windows, using multiprocessing requires the scripts to be + # "Safe importing of main module" to avoid RuntimeError. + # This restriction requires downstream tools to be modified to + # work. Instead, let's fallback to threading wrapper to get + # around it and still keep the parallelism on Windows. + import multiprocessing.dummy as multiprocessing +else: + import multiprocessing from .package import _get_package_xml from .package import PACKAGE_MANIFEST_FILENAME diff --git a/test/test_packages.py b/test/test_packages.py index fdae7994..128cc16c 100644 --- a/test/test_packages.py +++ b/test/test_packages.py @@ -49,7 +49,7 @@ def test_find_packages_allowing_duplicates_with_no_packages(): @in_temporary_directory def test_find_packages_invalid_version(): version = ':{version}' - path = 'src/foo' + path = os.path.normpath('src/foo') _create_pkg_in_dir(path, version) try: find_packages(path.split('/')[0]) From 8d2d2fb950be4bb10dfc03f8445d1219ae9c92e3 Mon Sep 17 00:00:00 2001 From: Sean Yen Date: Fri, 8 Feb 2019 23:19:26 -0800 Subject: [PATCH 2/3] fix. --- src/catkin_pkg/packages.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/catkin_pkg/packages.py b/src/catkin_pkg/packages.py index efaacdef..f9fb7503 100644 --- a/src/catkin_pkg/packages.py +++ b/src/catkin_pkg/packages.py @@ -33,6 +33,11 @@ """Library to find packages in the filesystem.""" import os + +from .package import _get_package_xml +from .package import PACKAGE_MANIFEST_FILENAME +from .package import parse_package_string + if os.name == 'nt': # https://docs.python.org/2/library/multiprocessing.html#windows # @@ -45,10 +50,6 @@ else: import multiprocessing -from .package import _get_package_xml -from .package import PACKAGE_MANIFEST_FILENAME -from .package import parse_package_string - def find_package_paths(basepath, exclude_paths=None, exclude_subspaces=False): """ From ccc4e2889b49142e524448a3af2f92fe1074057c Mon Sep 17 00:00:00 2001 From: "Sean Yen [MSFT]" Date: Mon, 11 Feb 2019 09:41:53 -0800 Subject: [PATCH 3/3] Fix. --- test/test_packages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_packages.py b/test/test_packages.py index 128cc16c..67f24e74 100644 --- a/test/test_packages.py +++ b/test/test_packages.py @@ -52,7 +52,7 @@ def test_find_packages_invalid_version(): path = os.path.normpath('src/foo') _create_pkg_in_dir(path, version) try: - find_packages(path.split('/')[0]) + find_packages(path.split(os.sep)[0]) assert False, 'Must raise' except InvalidPackage as e: exception_message = str(e)