From 051b6ed98af80810e787800b4c47bf985a208ed7 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 14 May 2019 19:39:08 +0200 Subject: [PATCH] test: use Travis CI to run tests on every pull request This is a second attempt at #1336 which got into a bad git-state... Use flake8 to find Python syntax errors and undefined names. There are Python 3 syntax errors and many undefined names which may raise NameError at runtime. This PR runs flake8 runs in two passes: The first looks at critical issues in stop-the-build mode and the second looks at style violations in everything-is-a-warning mode. PR-URL: https://github.com/nodejs/node-gyp/pull/1752 Reviewed-By: Rod Vagg --- .travis.yml | 24 ++++++++++++++++++++++++ gyp/pylib/gyp/MSVSVersion.py | 6 +++--- gyp/pylib/gyp/input.py | 2 +- gyp/pylib/gyp/xcode_emulation.py | 2 +- 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..7607d306fc --- /dev/null +++ b/.travis.yml @@ -0,0 +1,24 @@ +dist: xenial +language: python +cache: pip +python: + - 2.7 + - 3.7 +matrix: + allow_failures: + - python: 3.7 +install: + #- pip install -r requirements.txt + - pip install flake8 # pytest # add another testing frameworks later +before_script: + # stop the build if there are Python syntax errors or undefined names + - flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - npm install +script: + - npm test + #- pytest --capture=sys # add other tests here +notifications: + on_success: change + on_failure: change # `always` will be the setting once code changes slow down diff --git a/gyp/pylib/gyp/MSVSVersion.py b/gyp/pylib/gyp/MSVSVersion.py index 293b4145c1..13d9777f0e 100644 --- a/gyp/pylib/gyp/MSVSVersion.py +++ b/gyp/pylib/gyp/MSVSVersion.py @@ -178,15 +178,15 @@ def _RegistryGetValueUsingWinReg(key, value): """ try: # Python 2 - from _winreg import OpenKey, QueryValueEx + from _winreg import HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx except ImportError: # Python 3 - from winreg import OpenKey, QueryValueEx + from winreg import HKEY_LOCAL_MACHINE, OpenKey, QueryValueEx try: root, subkey = key.split('\\', 1) assert root == 'HKLM' # Only need HKLM for now. - with OpenKey(_winreg.HKEY_LOCAL_MACHINE, subkey) as hkey: + with OpenKey(HKEY_LOCAL_MACHINE, subkey) as hkey: return QueryValueEx(hkey, value)[0] except WindowsError: return None diff --git a/gyp/pylib/gyp/input.py b/gyp/pylib/gyp/input.py index 68e51131d8..eb9858f0c8 100644 --- a/gyp/pylib/gyp/input.py +++ b/gyp/pylib/gyp/input.py @@ -1182,7 +1182,7 @@ def LoadVariablesFromVariablesDict(variables, the_dict, the_dict_key): if variable_name in variables: # If the variable is already set, don't set it. continue - if the_dict_key is 'variables' and variable_name in the_dict: + if the_dict_key == 'variables' and variable_name in the_dict: # If the variable is set without a % in the_dict, and the_dict is a # variables dict (making |variables| a varaibles sub-dict of a # variables dict), use the_dict's definition. diff --git a/gyp/pylib/gyp/xcode_emulation.py b/gyp/pylib/gyp/xcode_emulation.py index 66f325932a..6ae41e293a 100644 --- a/gyp/pylib/gyp/xcode_emulation.py +++ b/gyp/pylib/gyp/xcode_emulation.py @@ -844,7 +844,7 @@ def GetLdflags(self, configname, product_dir, gyp_to_build_path, arch=None): if self._IsXCTest(): platform_root = self._XcodePlatformPath(configname) if platform_root: - cflags.append('-F' + platform_root + '/Developer/Library/Frameworks/') + cflags.append('-F' + platform_root + '/Developer/Library/Frameworks/') # noqa TODO @cclauss is_extension = self._IsIosAppExtension() or self._IsIosWatchKitExtension() if sdk_root and is_extension: