2024-05-27 16:40:49 +03:00
|
|
|
# shellcheck shell=bash
|
|
|
|
|
2023-11-08 07:30:55 +02:00
|
|
|
# Remove overall test dir (at most one of the two should match) and
|
|
|
|
# remove file extension.
|
2024-05-27 16:40:49 +03:00
|
|
|
|
2024-05-28 17:10:02 +03:00
|
|
|
test_name=$(echo -n "${test?must be defined by caller (test runner)}" | sed \
|
2024-06-27 18:28:08 +03:00
|
|
|
-e "s|^src/[^/]*-test/data/||" \
|
2023-11-08 07:30:55 +02:00
|
|
|
-e "s|^tests/functional/||" \
|
|
|
|
-e "s|\.sh$||" \
|
|
|
|
)
|
2023-10-05 19:12:18 +03:00
|
|
|
|
2024-05-27 16:40:49 +03:00
|
|
|
# shellcheck disable=SC2016
|
2023-11-08 07:30:55 +02:00
|
|
|
TESTS_ENVIRONMENT=(
|
|
|
|
"TEST_NAME=$test_name"
|
|
|
|
'NIX_REMOTE='
|
|
|
|
'PS4=+(${BASH_SOURCE[0]-$0}:$LINENO) '
|
|
|
|
)
|
2022-12-16 03:17:08 +02:00
|
|
|
|
2024-05-27 16:40:49 +03:00
|
|
|
read -r -a bash <<< "${BASH:-/usr/bin/env bash}"
|
2022-12-16 03:17:08 +02:00
|
|
|
|
2023-11-08 07:30:55 +02:00
|
|
|
run () {
|
2024-05-27 16:40:49 +03:00
|
|
|
cd "$(dirname "$1")" && env "${TESTS_ENVIRONMENT[@]}" "${bash[@]}" -x -e -u -o pipefail "$(basename "$1")"
|
2023-11-08 07:30:55 +02:00
|
|
|
}
|