summaryrefslogtreecommitdiff
path: root/share/spack/qa/run-unit-tests
blob: 8ba6eed350064de7a0d19bef80a1628be739ddf3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash -e
#
# Copyright 2013-2020 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

#
# Description:
#     Runs Spack unit tests.
#
# Usage:
#     run-unit-tests [test ...]
#
# Options:
#     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

# Move to root directory of Spack
# Allows script to be run from anywhere
cd "$SPACK_ROOT"

# Print compiler information
spack config get compilers

# Run spack help to cover command import
bin/spack -h
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 -x --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