Skip to content

Commit

Permalink
tests: add tests for setup-env.sh
Browse files Browse the repository at this point in the history
- tests use a shell-script harness and test all Spack commands that
  require special shell support.

- tests work in bash, zsh, and dash

- run setup-env.sh tests on macos and linux builds.
  - we run them on macos and linux
  • Loading branch information
tgamblin committed Jul 5, 2019
1 parent 82452a7 commit 7ed82f9
Show file tree
Hide file tree
Showing 5 changed files with 343 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ ignore:
- lib/spack/spack/test/.*
- lib/spack/docs/.*
- lib/spack/external/.*
- share/spack/qa/.*
- share/spack/spack-completion.bash

comment: off
33 changes: 10 additions & 23 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,6 @@ jobs:
os: linux
language: python
env: [ TEST_SUITE=unit, COVERAGE=true ]
addons:
apt:
packages:
- cmake
- gfortran
- graphviz
- gnupg2
- kcov
- mercurial
- ninja-build
- perl
- perl-base
- realpath
- patchelf
- r-base
- r-base-core
- r-base-dev

- python: '3.7'
sudo: required
os: linux
Expand Down Expand Up @@ -159,13 +141,16 @@ addons:
- r-base
- r-base-core
- r-base-dev
- zsh
# for Mac builds, we use Homebrew
homebrew:
packages:
- python@2
- gcc
- gnupg2
- ccache
- dash
- kcov
update: true

# ~/.ccache needs to be cached directly as Travis is not taking care of it
Expand Down Expand Up @@ -223,11 +208,13 @@ script:

after_success:
- ccache -s
- if [[ "$TEST_SUITE" == "unit" || "$TEST_SUITE" == "build" ]]; then
codecov --env PYTHON_VERSION
--required
--flags "${TEST_SUITE}${TRAVIS_OS_NAME}";
fi
- case "$TEST_SUITE" in
unit)
codecov --env PYTHON_VERSION
--required
--flags "${TEST_SUITE}${TRAVIS_OS_NAME}";
;;
esac

#=============================================================================
# Notifications
Expand Down
30 changes: 30 additions & 0 deletions share/spack/qa/run-unit-tests
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
# Optionally add one or more unit tests
# to only run these tests.
#

#-----------------------------------------------------------
# Run a few initial commands and set up test environment
#-----------------------------------------------------------
ORIGINAL_PATH="$PATH"

. "$(dirname $0)/setup.sh"
check_dependencies ${coverage} git hg svn

Expand All @@ -33,9 +39,33 @@ bin/spack help -a
# Profile and print top 20 lines for a simple call to spack spec
bin/spack -p --lines 20 spec mpileaks%gcc ^elfutils@0.170

#-----------------------------------------------------------
# Run unit tests with code coverage
#-----------------------------------------------------------
extra_args=""
if [[ -n "$@" ]]; then
extra_args="-k $@"
fi
${coverage_run} bin/spack test --verbose "$extra_args"

#-----------------------------------------------------------
# Run tests for setup-env.sh
#-----------------------------------------------------------
# Clean the environment by removing Spack from the path and getting rid of
# the spack shell function
export PATH="$ORIGINAL_PATH"
unset spack

# start in the spack root directory
cd $SPACK_ROOT

# Run bash tests with coverage enabled, but pipe output to /dev/null
# because it seems that kcov seems to undo the script's redirection
if [ "$BASH_COVERAGE" = true ]; then
${QA_DIR}/bashcov ${QA_DIR}/setup-env-test.sh &> /dev/null
fi

# run the test scripts for their output (these will print nicely)
bash ${QA_DIR}/setup-env-test.sh
zsh ${QA_DIR}/setup-env-test.sh
dash ${QA_DIR}/setup-env-test.sh
Loading

0 comments on commit 7ed82f9

Please sign in to comment.