summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2016-08-23 09:45:46 -0400
committerErik Schnetter <schnetter@gmail.com>2016-08-23 09:45:46 -0400
commit64d3f87e605f596c149152bbab98ad3cfc89d549 (patch)
tree8b767ef2943afafdd6b9932fba2b509d4fe344b7 /share
parente43eaad5570009622bf0b19b2a9df2f7e70f8f3e (diff)
parente81f3daa2836c4eb8a7d4e6d0f2cfc6b65875612 (diff)
downloadspack-64d3f87e605f596c149152bbab98ad3cfc89d549.tar.gz
spack-64d3f87e605f596c149152bbab98ad3cfc89d549.tar.bz2
spack-64d3f87e605f596c149152bbab98ad3cfc89d549.tar.xz
spack-64d3f87e605f596c149152bbab98ad3cfc89d549.zip
Merge branch 'develop' into eschnett/sympol
Diffstat (limited to 'share')
-rw-r--r--share/spack/csh/convert-pyext.sh5
-rw-r--r--share/spack/csh/spack.csh8
-rwxr-xr-xshare/spack/qa/run-flake867
-rwxr-xr-xshare/spack/qa/run-unit-tests20
-rwxr-xr-xshare/spack/setup-env.sh28
5 files changed, 93 insertions, 35 deletions
diff --git a/share/spack/csh/convert-pyext.sh b/share/spack/csh/convert-pyext.sh
new file mode 100644
index 0000000000..a48bcdbcca
--- /dev/null
+++ b/share/spack/csh/convert-pyext.sh
@@ -0,0 +1,5 @@
+#!/bin/bash --noprofile
+PYEXT_REGEX=".*/.*/package.py"
+
+find var/spack/repos/builtin/packages/ -type f -regextype sed -regex ${PYEXT_REGEX} -exec \
+ sed -i 's/python('\''setup.py'\'', /setup_py(/' {} \;
diff --git a/share/spack/csh/spack.csh b/share/spack/csh/spack.csh
index d64ce8935b..5acd190449 100644
--- a/share/spack/csh/spack.csh
+++ b/share/spack/csh/spack.csh
@@ -74,25 +74,25 @@ case unload:
# tool's commands to add/remove the result from the environment.
switch ($_sp_subcommand)
case "use":
- set _sp_full_spec = ( "`\spack $_sp_flags module find dotkit $_sp_spec`" )
+ set _sp_full_spec = ( "`\spack $_sp_flags module find --module-type dotkit $_sp_spec`" )
if ( $? == 0 ) then
use $_sp_module_args $_sp_full_spec
endif
breaksw
case "unuse":
- set _sp_full_spec = ( "`\spack $_sp_flags module find dotkit $_sp_spec`" )
+ set _sp_full_spec = ( "`\spack $_sp_flags module find --module-type dotkit $_sp_spec`" )
if ( $? == 0 ) then
unuse $_sp_module_args $_sp_full_spec
endif
breaksw
case "load":
- set _sp_full_spec = ( "`\spack $_sp_flags module find tcl $_sp_spec`" )
+ set _sp_full_spec = ( "`\spack $_sp_flags module find --module-type tcl $_sp_spec`" )
if ( $? == 0 ) then
module load $_sp_module_args $_sp_full_spec
endif
breaksw
case "unload":
- set _sp_full_spec = ( "`\spack $_sp_flags module find tcl $_sp_spec`" )
+ set _sp_full_spec = ( "`\spack $_sp_flags module find --module-type tcl $_sp_spec`" )
if ( $? == 0 ) then
module unload $_sp_module_args $_sp_full_spec
endif
diff --git a/share/spack/qa/run-flake8 b/share/spack/qa/run-flake8
index 44eb0167fb..e41cd0d471 100755
--- a/share/spack/qa/run-flake8
+++ b/share/spack/qa/run-flake8
@@ -2,11 +2,6 @@
#
# 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
@@ -17,47 +12,73 @@ if [[ ! $flake8 ]]; then
exit 1
fi
-# Check if changed files are flake8 conformant [framework]
-changed=$(git diff --name-only develop... | grep '.py$')
+# Move to Spack root; allows script to be run from anywhere
+cd "$(dirname "$0")/../../.."
+
+# Add changed files that have been committed since branching off of develop
+changed=($(git diff --name-only --find-renames develop... -- '*.py'))
+# Add changed files that have been staged but not yet committed
+changed+=($(git diff --name-only --find-renames --cached -- '*.py'))
+# Add changed files that are unstaged
+changed+=($(git diff --name-only --find-renames -- '*.py'))
+
+# Ensure that each file in the array is unique
+changed=($(printf '%s\n' "${changed[@]}" | sort -u))
+
+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
- if [[ $file = *package.py ]]; then
- cp "$file" "$file~"
+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
+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 "${changed[@]}" | perl -pe 's/^/ /;s/ +/\n /g'
echo =======================================================
- if flake8 --format pylint $changed; then
+ if flake8 --format pylint "${changed[@]}"; then
echo "Flake8 checks were clean."
else
echo "Flake8 found errors."
- return_code=1
+ exit 1
fi
else
echo No core framework files modified.
fi
-# Restore original package files after modifying them.
-for file in $changed; do
- if [[ $file = *package.py ]]; then
- mv "${file}~" "${file}"
- fi
-done
-
-exit $return_code
+exit 0
diff --git a/share/spack/qa/run-unit-tests b/share/spack/qa/run-unit-tests
new file mode 100755
index 0000000000..33fb1bfae2
--- /dev/null
+++ b/share/spack/qa/run-unit-tests
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+#
+# This script runs Spack unit tests.
+#
+# It should be executed from the top-level directory of the repo,
+# e.g.:
+#
+# share/spack/qa/run-unit-tests
+#
+# To run it, you'll need to have the Python coverage installed locally.
+#
+
+# Regular spack setup and tests
+. ./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
diff --git a/share/spack/setup-env.sh b/share/spack/setup-env.sh
index 8aa259cf15..2eb1dfecb3 100755
--- a/share/spack/setup-env.sh
+++ b/share/spack/setup-env.sh
@@ -57,6 +57,11 @@
########################################################################
function spack {
+ # Zsh does not do word splitting by default, this enables it for this function only
+ if [ -n "$ZSH_VERSION" ]; then
+ emulate -L sh
+ fi
+
# save raw arguments into an array before butchering them
args=( "$@" )
@@ -93,11 +98,18 @@ function spack {
;;
"use"|"unuse"|"load"|"unload")
# Shift any other args for use off before parsing spec.
+ _sp_subcommand_args=""
_sp_module_args=""
- if [[ "$1" =~ ^- ]]; then
- _sp_module_args="$1"; shift
- _sp_spec="$@"
- fi
+ while [[ "$1" =~ ^- ]]; do
+ if [ "$1" = "-r" -o "$1" = "--dependencies" ]; then
+ _sp_subcommand_args="$_sp_subcommand_args $1"
+ else
+ _sp_module_args="$_sp_module_args $1"
+ fi
+ shift
+ done
+
+ _sp_spec="$@"
# Here the user has run use or unuse with a spec. Find a matching
# spec using 'spack module find', then use the appropriate module
@@ -105,19 +117,19 @@ function spack {
# If spack module command comes back with an error, do nothing.
case $_sp_subcommand in
"use")
- if _sp_full_spec=$(command spack $_sp_flags module find dotkit $_sp_spec); then
+ if _sp_full_spec=$(command spack $_sp_flags module loads --input-only $_sp_subcommand_args --module-type dotkit $_sp_spec); then
use $_sp_module_args $_sp_full_spec
fi ;;
"unuse")
- if _sp_full_spec=$(command spack $_sp_flags module find dotkit $_sp_spec); then
+ if _sp_full_spec=$(command spack $_sp_flags module loads --input-only $_sp_subcommand_args --module-type dotkit $_sp_spec); then
unuse $_sp_module_args $_sp_full_spec
fi ;;
"load")
- if _sp_full_spec=$(command spack $_sp_flags module find tcl $_sp_spec); then
+ if _sp_full_spec=$(command spack $_sp_flags module loads --input-only $_sp_subcommand_args --module-type tcl $_sp_spec); then
module load $_sp_module_args $_sp_full_spec
fi ;;
"unload")
- if _sp_full_spec=$(command spack $_sp_flags module find tcl $_sp_spec); then
+ if _sp_full_spec=$(command spack $_sp_flags module loads --input-only $_sp_subcommand_args --module-type tcl $_sp_spec); then
module unload $_sp_module_args $_sp_full_spec
fi ;;
esac