aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/check.sh
blob: dbfa67deb90ad242f7d8226a890e11263f1ae6b9 (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
#! /usr/bin/env sh

git_root="$(git rev-parse --show-toplevel)"

fmt_check() {
    echo ".#checks.x86_64-linux.$1"
}

failed="$(mktemp -t server_check_XXXXX)"
trap 'rm -f "$failed"' EXIT
trap 'exit 4' HUP INT QUIT TERM

# We want word-splitting for the arg
# shellcheck disable=SC2046
set -- $(nix eval --file "$git_root/scripts/check_get_tests.nix" --raw)

while [ "$#" -ne 0 ]; do
    test="$1"
    shift 1

    echo "Building test '$test'..."
    fmt_test="$(fmt_check "$test")"

    if ! nix build \
        --option max-jobs 1 \
        --print-out-paths \
        --no-link \
        "$fmt_test"; then
        echo "$test" >>"$failed"
    fi
done

if [ "$(cat "$failed" | wc -l)" -ne 0 ]; then
    echo "Failed tests:"
    while read -r test; do
        echo "  - $test"
    done <"$failed"
fi