diff options
author | alalazo <massimiliano.culpo@googlemail.com> | 2016-09-04 10:12:52 +0200 |
---|---|---|
committer | alalazo <massimiliano.culpo@googlemail.com> | 2016-09-04 10:12:52 +0200 |
commit | 47f6a6d3cfd1285fb5d8cd95a415c8a24045b330 (patch) | |
tree | 8f0b73ead979cd5e9f8181642d0ee1cf1ddff79b /share | |
parent | f5433477b9f7c98ca00947cf1b1fdc106cca1080 (diff) | |
parent | 16c5403ab3ca35dfa6d715ce2c5434c65de81c17 (diff) | |
download | spack-47f6a6d3cfd1285fb5d8cd95a415c8a24045b330.tar.gz spack-47f6a6d3cfd1285fb5d8cd95a415c8a24045b330.tar.bz2 spack-47f6a6d3cfd1285fb5d8cd95a415c8a24045b330.tar.xz spack-47f6a6d3cfd1285fb5d8cd95a415c8a24045b330.zip |
Merge branch 'develop' of https://github.com/LLNL/spack into features/install_with_phases_rebase
Conflicts:
lib/spack/spack/build_environment.py
lib/spack/spack/package.py
var/spack/repos/builtin/packages/astyle/package.py
var/spack/repos/builtin/packages/lzo/package.py
var/spack/repos/builtin/packages/openjpeg/package.py
var/spack/repos/builtin/packages/swiftsim/package.py
Diffstat (limited to 'share')
-rwxr-xr-x | share/spack/qa/changed_files | 31 | ||||
-rwxr-xr-x | share/spack/qa/check_dependencies | 67 | ||||
-rwxr-xr-x | share/spack/qa/run-doc-tests | 43 | ||||
-rwxr-xr-x | share/spack/qa/run-flake8 | 75 | ||||
-rwxr-xr-x | share/spack/qa/run-flake8-tests | 89 | ||||
-rwxr-xr-x | share/spack/qa/run-unit-tests | 42 |
6 files changed, 264 insertions, 83 deletions
diff --git a/share/spack/qa/changed_files b/share/spack/qa/changed_files new file mode 100755 index 0000000000..9c60b3b20b --- /dev/null +++ b/share/spack/qa/changed_files @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +# +# Description: +# Returns a list of changed files. +# +# Usage: +# changed_files [<directory> ...] +# changed_files [<file> ...] +# changed_files ["*.<extension>" ...] +# +# Options: +# Directories, files, or globs to search for changed files. +# + +# Move to root directory of Spack +# Allows script to be run from anywhere +SPACK_ROOT="$(dirname "$0")/../../.." +cd "$SPACK_ROOT" + +# Add changed files that have been committed since branching off of develop +changed=($(git diff --name-only --find-renames develop... -- "$@")) +# Add changed files that have been staged but not yet committed +changed+=($(git diff --name-only --find-renames --cached -- "$@")) +# Add changed files that are unstaged +changed+=($(git diff --name-only --find-renames -- "$@")) +# Add new files that are untracked +changed+=($(git ls-files --exclude-standard --other -- "$@")) + +# Return array +# Ensure that each file in the array is unique +printf '%s\n' "${changed[@]}" | sort -u diff --git a/share/spack/qa/check_dependencies b/share/spack/qa/check_dependencies new file mode 100755 index 0000000000..08fad9cdc9 --- /dev/null +++ b/share/spack/qa/check_dependencies @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +# +# Description: +# Check to see if dependencies are installed. +# If not, warn the user and tell them how to +# install these dependencies. +# +# Usage: +# check-deps <dep> ... +# +# Options: +# One or more dependencies. Must use name of binary. + +for dep in "$@"; do + if ! which $dep &> /dev/null; then + # Map binary name to package name + case $dep in + sphinx-apidoc|sphinx-build) + spack_package=py-sphinx + pip_package=sphinx + ;; + coverage) + spack_package=py-coverage + pip_package=coverage + ;; + flake8) + spack_package=py-flake8 + pip_package=flake8 + ;; + git) + spack_package=git + ;; + hg) + spack_package=mercurial + pip_package=mercurial + ;; + svn) + spack_package=subversion + ;; + *) + spack_package=$dep + pip_package=$dep + ;; + esac + + echo "ERROR: $dep is required to run this script." + echo + + if [[ $spack_package ]]; then + echo "To install with Spack, run:" + echo " $ spack install $spack_package" + fi + + if [[ $pip_package ]]; then + echo "To install with pip, run:" + echo " $ pip install $pip_package" + fi + + if [[ $spack_package || $pip_package ]]; then + echo "Then add the bin directory to your PATH." + fi + + exit 1 + fi +done + +echo "Dependencies found." diff --git a/share/spack/qa/run-doc-tests b/share/spack/qa/run-doc-tests new file mode 100755 index 0000000000..96b76a216e --- /dev/null +++ b/share/spack/qa/run-doc-tests @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# +# Description: +# Builds Spack documentation and checks for +# possible syntax errors. Treats warnings as +# fatal errors. +# +# Usage: +# run-doc-tests +# +# Notes: +# Requires sphinx, git, mercurial, and subversion. +# + +QA_DIR="$(dirname "$0")" +SPACK_ROOT="$QA_DIR/../../.." +DOC_DIR="$SPACK_ROOT/lib/spack/docs" + +# Array of dependencies +deps=( + sphinx-apidoc + sphinx-build + git + hg + svn +) + +# Check for dependencies +"$QA_DIR/check_dependencies" "${deps[@]}" || exit 1 + +# Add Spack to the PATH. +export PATH="$SPACK_ROOT/bin:$PATH" + +# Move to documentation directory +# Allows script to be run from anywhere +cd "$DOC_DIR" + +# Cleanup temporary files upon exit or when script is killed +trap 'make clean --silent' EXIT SIGINT SIGTERM + +# Treat warnings as fatal errors +make SPHINXOPTS=-W + diff --git a/share/spack/qa/run-flake8 b/share/spack/qa/run-flake8 deleted file mode 100755 index c59bfc9490..0000000000 --- a/share/spack/qa/run-flake8 +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# -# This script runs source code style checks on Spack. -# -# It should be executed from the top-level directory of the repo, -# e.g.: -# -# share/spack/qa/run-flake8 -# -# To run it, you'll need to have the Python flake8 installed locally. -# -PYTHONPATH=./lib/spack:$PYTHONPATH - -flake8="$(which flake8)" -if [[ ! $flake8 ]]; then - echo "ERROR: flake8 is required to run this script." - exit 1 -fi - -# Check if changed files are flake8 conformant [framework] -changed=$(git diff --name-only --find-renames develop... | grep '.py$') - -# 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 - -return_code=0 -if [[ $changed ]]; then - 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." - return_code=1 - fi -else - echo No core framework files modified. -fi - -# Restore original package files after modifying them. -for file in $changed; do - if [[ -e "${file}.sbak~" ]]; then - mv "${file}.sbak~" "${file}" - fi -done - -exit $return_code diff --git a/share/spack/qa/run-flake8-tests b/share/spack/qa/run-flake8-tests new file mode 100755 index 0000000000..350ef3161f --- /dev/null +++ b/share/spack/qa/run-flake8-tests @@ -0,0 +1,89 @@ +#!/usr/bin/env bash +# +# Description: +# Runs source code style checks on Spack. +# See $SPACK_ROOT/.flake8 for a list of +# approved exceptions. +# +# Usage: +# run-flake8-tests +# +# Notes: +# Requires flake8. +# + +QA_DIR="$(dirname "$0")" +SPACK_ROOT="$QA_DIR/../../.." + +# Array of dependencies +deps=( + flake8 +) + +# Check for dependencies +"$QA_DIR/check_dependencies" "${deps[@]}" || exit 1 + +# Move to root directory of Spack +# Allows script to be run from anywhere +cd "$SPACK_ROOT" + +# Gather array of changed files +changed=($("$QA_DIR/changed_files" "*.py")) + +# Exit if no Python files were modified +if [[ ! "${changed[@]}" ]]; then + echo "No Python files were modified." + exit 0 +fi + +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 diff --git a/share/spack/qa/run-unit-tests b/share/spack/qa/run-unit-tests index 33fb1bfae2..6da919e18d 100755 --- a/share/spack/qa/run-unit-tests +++ b/share/spack/qa/run-unit-tests @@ -1,20 +1,46 @@ #!/usr/bin/env bash # -# This script runs Spack unit tests. +# Description: +# Runs Spack unit tests. # -# It should be executed from the top-level directory of the repo, -# e.g.: +# Usage: +# run-unit-tests [test ...] # -# share/spack/qa/run-unit-tests +# Options: +# Optionally add one or more unit tests +# to only run these tests. # -# To run it, you'll need to have the Python coverage installed locally. +# Notes: +# Requires coverage, git, mercurial, and subversion. # -# Regular spack setup and tests -. ./share/spack/setup-env.sh +QA_DIR="$(dirname "$0")" +SPACK_ROOT="$QA_DIR/../../.." + +# Array of dependencies +deps=( + coverage + git + hg + svn +) + +# Check for dependencies +"$QA_DIR/check_dependencies" "${deps[@]}" || exit 1 + +# Add Spack to the PATH. +export PATH="$SPACK_ROOT/bin:$PATH" + +# Move to root directory of Spack +# Allows script to be run from anywhere +cd "$SPACK_ROOT" + +# Run integration tests +# TODO: should these be separated into a different test suite? +source "$SPACK_ROOT/share/spack/setup-env.sh" spack compilers spack config get compilers spack install -v libdwarf # Run unit tests with code coverage -coverage run bin/spack test +coverage run bin/spack test "$@" |