summaryrefslogtreecommitdiff
path: root/share/spack/qa/run-unit-tests
blob: 9ce3062e58f4655ba7723e97d91081d00bb67197 (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
#!/usr/bin/env bash
#
# Description:
#     Runs Spack unit tests.
#
# Usage:
#     run-unit-tests [test ...]
#
# Options:
#     Optionally add one or more unit tests
#     to only run these tests.
#
# Notes:
#     Requires coverage.
#

QA_DIR="$(dirname "$0")"
SPACK_ROOT="$QA_DIR/../../.."

# Array of dependencies
deps=(
    coverage
)

# Check for dependencies
"$QA_DIR/check_dependencies" "${deps[@]}" || exit 1

# Add Spack to the PATH.
export PATH="$SPACK_ROOT/bin:$PATH"

# Array of directories containing core Spack framework
core_dirs=(
    bin
    etc
    # lib, but skip documentation
    lib/spack/env
    lib/spack/external
    lib/spack/llnl
    lib/spack/spack
    share
)

# Gather array of changed files
changed=($("$QA_DIR/changed_files" "${core_dirs[@]}"))

# Exit if no core Spack framework files were modified
if [[ ! "${changed[@]}" ]]; then
    echo "No core Spack framework files were modified."
    exit 0
fi

# 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 spack test "$@"