summaryrefslogtreecommitdiff
path: root/share/spack/qa/setup.sh
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2017-04-27 11:47:56 -0700
committerGitHub <noreply@github.com>2017-04-27 11:47:56 -0700
commitbb5a433a46a8ffc69b01e8477eb6646f4c66f9d2 (patch)
treedc20c9c224a85eda36661b1af6be5e8ad3e6e4d2 /share/spack/qa/setup.sh
parenta0ebce0cb3824d154e405d8044ded1aea5e26e12 (diff)
downloadspack-bb5a433a46a8ffc69b01e8477eb6646f4c66f9d2.tar.gz
spack-bb5a433a46a8ffc69b01e8477eb6646f4c66f9d2.tar.bz2
spack-bb5a433a46a8ffc69b01e8477eb6646f4c66f9d2.tar.xz
spack-bb5a433a46a8ffc69b01e8477eb6646f4c66f9d2.zip
Separate integration tests; simplify test scripts (#4006)
* Separate build integration tests; simplify test scripts - Move build tests out of the regular Travis unit tests, add more smoke test packages to build. - Run all test scripts with bash -e, which fails on error. - Factor coverage out into a Travis environment variable, so it's more obvious from .travis.yml which tests contribute to coverage and which don't. - Factor dependency checking and much of the front-matter in tests scripts into a setup.sh script, which is sourced by all the test scripts. Extra cruft in each tests script now reduced to 2 lines at the beginning.
Diffstat (limited to 'share/spack/qa/setup.sh')
-rwxr-xr-xshare/spack/qa/setup.sh118
1 files changed, 118 insertions, 0 deletions
diff --git a/share/spack/qa/setup.sh b/share/spack/qa/setup.sh
new file mode 100755
index 0000000000..98c79a0457
--- /dev/null
+++ b/share/spack/qa/setup.sh
@@ -0,0 +1,118 @@
+#!/bin/bash -e
+#
+# Description:
+# Common setup code to be sourced by Spack's test scripts.
+#
+
+QA_DIR="$(dirname ${BASH_SOURCE[0]})"
+SPACK_ROOT="$QA_DIR/../../.."
+
+# Source the setup script
+. "$SPACK_ROOT/share/spack/setup-env.sh"
+
+# Set up some variables for running coverage tests.
+if [[ "$COVERAGE" == true ]]; then
+ coverage=coverage
+ coverage_run="coverage run"
+ coverage_combine="coverage combine"
+else
+ coverage=""
+ coverage_run=""
+ coverage_combine=""
+fi
+
+#
+# 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.
+check_dependencies() {
+ 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
+ ;;
+ dot)
+ spack_package=graphviz
+ ;;
+ 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
+
+ # Flake8 and Sphinx require setuptools in order to run.
+ # Otherwise, they print out this error message:
+ #
+ # Traceback (most recent call last):
+ # File: "/usr/bin/flake8", line 5, in <module>
+ # from pkg_resources import load_entry_point
+ # ImportError: No module named pkg_resources
+ #
+ # Print a more useful error message if setuptools not found.
+ if [[ $dep == flake8 || $dep == sphinx* ]]; then
+ # Find which Python is being run
+ # Spack-installed packages have a hard-coded shebang
+ python_cmd=$(head -n 1 $(which $dep) | cut -c 3-)
+ # May not have a shebang
+ if [[ $python_cmd != *python* ]]; then
+ python_cmd=python
+ fi
+ # Check if setuptools is in the PYTHONPATH
+ if ! $python_cmd -c "import setuptools" 2> /dev/null; then
+ echo "ERROR: setuptools is required to run $dep."
+ echo "Please add it to your PYTHONPATH."
+
+ exit 1
+ fi
+ fi
+ done
+ echo "Dependencies found."
+}