diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2016-10-31 11:40:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-31 11:40:20 -0700 |
commit | 1b7f9e24f49990c6bee245916e080a1fc891162f (patch) | |
tree | d9c5124884321a681d2931473bec0d16d19c3a0c /share | |
parent | 4be703cde0c8771cb9f128ac826db18ab91767b7 (diff) | |
download | spack-1b7f9e24f49990c6bee245916e080a1fc891162f.tar.gz spack-1b7f9e24f49990c6bee245916e080a1fc891162f.tar.bz2 spack-1b7f9e24f49990c6bee245916e080a1fc891162f.tar.xz spack-1b7f9e24f49990c6bee245916e080a1fc891162f.zip |
Add `spack flake8` command. (#2186)
- Ported old run-flake8-tests qa script to `spack flake8` command.
- New command does not modify files in the source tree
- Copies files to a temp stage modifies them there, and runs tests.
- Updated docs and `run-flake8-tests` script to call `spack flake8`.
Diffstat (limited to 'share')
-rwxr-xr-x | share/spack/qa/run-flake8-tests | 66 |
1 files changed, 3 insertions, 63 deletions
diff --git a/share/spack/qa/run-flake8-tests b/share/spack/qa/run-flake8-tests index 6fe97160e3..83469eeb9d 100755 --- a/share/spack/qa/run-flake8-tests +++ b/share/spack/qa/run-flake8-tests @@ -23,67 +23,7 @@ deps=( # Check for dependencies "$QA_DIR/check_dependencies" "${deps[@]}" || exit 1 -# Gather array of changed files -changed=($("$QA_DIR/changed_files" "*.py")) +# Add Spack to the PATH. +export PATH="$SPACK_ROOT/bin:$PATH" -# Exit if no Python files were modified -if [[ ! "${changed[@]}" ]]; then - echo "No Python files were modified." - exit 0 -fi - -# Move to root directory of Spack -# Allows script to be run from anywhere -cd "$SPACK_ROOT" - -function cleanup { - # Restore original package files after modifying them. - for file in "${changed[@]}"; do - if [[ -e "${file}.sbak~" ]]; then - mv "${file}.sbak~" "${file}" - fi - done -} - -# Cleanup temporary files upon exit or when script is killed -trap cleanup EXIT SIGINT SIGTERM - -# Add approved style exemptions to the changed packages. -for file in "${changed[@]}"; do - # Make a backup to restore later - cp "$file" "$file.sbak~" - - # - # Exemptions for package.py files - # - if [[ $file = *package.py ]]; then - # Exempt lines with urls and descriptions from overlong line errors. - perl -i -pe 's/^(\s*homepage\s*=.*)$/\1 # NOQA: ignore=E501/' "$file" - perl -i -pe 's/^(\s*url\s*=.*)$/\1 # NOQA: ignore=E501/' "$file" - perl -i -pe 's/^(\s*version\(.*\).*)$/\1 # NOQA: ignore=E501/' "$file" - perl -i -pe 's/^(\s*variant\(.*\).*)$/\1 # NOQA: ignore=E501/' "$file" - perl -i -pe 's/^(\s*depends_on\(.*\).*)$/\1 # NOQA: ignore=E501/' "$file" - perl -i -pe 's/^(\s*extends\(.*\).*)$/\1 # NOQA: ignore=E501/' "$file" - - # Exempt '@when' decorated functions from redefinition errors. - perl -i -pe 's/^(\s*\@when\(.*\).*)$/\1 # NOQA: ignore=F811/' "$file" - fi - - # - # Exemptions for all files - # - perl -i -pe 's/^(.*(https?|file)\:.*)$/\1 # NOQA: ignore=E501/' $file -done - -echo ======================================================= -echo flake8: running flake8 code checks on spack. -echo -echo Modified files: -echo "${changed[@]}" | perl -pe 's/^/ /;s/ +/\n /g' -echo ======================================================= -if flake8 --format pylint "${changed[@]}"; then - echo "Flake8 checks were clean." -else - echo "Flake8 found errors." - exit 1 -fi +exec spack flake8 |