From 1b7f9e24f49990c6bee245916e080a1fc891162f Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Mon, 31 Oct 2016 11:40:20 -0700 Subject: 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`. --- share/spack/qa/run-flake8-tests | 66 ++--------------------------------------- 1 file changed, 3 insertions(+), 63 deletions(-) (limited to 'share') 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 -- cgit v1.2.3-70-g09d2