mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-14 10:16:15 +02:00
9afa697ab6
The basic idea here is to separate a few intertwined notions: 1. Not all "run bash tests" are "install tests" 2. Not all "run bash tests" use `tests/functional/init.sh`, or any pre-test initialization at all. This will used in the next commit when we have a test that check unit test golden master data. Also, move our custom `PS4` from the test to the test runner, as it is part of how we want to display the tests, not the test themselves. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
27 lines
568 B
Bash
27 lines
568 B
Bash
# Remove overall test dir (at most one of the two should match) and
|
|
# remove file extension.
|
|
test_name=$(echo -n "$test" | sed \
|
|
-e "s|^unit-test-data/||" \
|
|
-e "s|^tests/functional/||" \
|
|
-e "s|\.sh$||" \
|
|
)
|
|
|
|
TESTS_ENVIRONMENT=(
|
|
"TEST_NAME=$test_name"
|
|
'NIX_REMOTE='
|
|
'PS4=+(${BASH_SOURCE[0]-$0}:$LINENO) '
|
|
)
|
|
|
|
: ${BASH:=/usr/bin/env bash}
|
|
|
|
run () {
|
|
cd "$(dirname $1)" && env "${TESTS_ENVIRONMENT[@]}" $BASH -x -e -u -o pipefail $(basename $1)
|
|
}
|
|
|
|
init_test () {
|
|
run "$init" 2>/dev/null > /dev/null
|
|
}
|
|
|
|
run_test_proper () {
|
|
run "$test"
|
|
}
|