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>
41 lines
710 B
Bash
Executable file
41 lines
710 B
Bash
Executable file
#!/usr/bin/env bash
|
||
|
||
set -eu -o pipefail
|
||
|
||
red=""
|
||
green=""
|
||
yellow=""
|
||
normal=""
|
||
|
||
test=$1
|
||
init=${2-}
|
||
|
||
dir="$(dirname "${BASH_SOURCE[0]}")"
|
||
source "$dir/common-test.sh"
|
||
|
||
post_run_msg="ran test $test..."
|
||
if [ -t 1 ]; then
|
||
red="[31;1m"
|
||
green="[32;1m"
|
||
yellow="[33;1m"
|
||
normal="[m"
|
||
fi
|
||
|
||
run_test () {
|
||
if [ -n "$init" ]; then
|
||
(init_test 2>/dev/null > /dev/null)
|
||
fi
|
||
log="$(run_test_proper 2>&1)" && status=0 || status=$?
|
||
}
|
||
|
||
run_test
|
||
|
||
if [ $status -eq 0 ]; then
|
||
echo "$post_run_msg [${green}PASS$normal]"
|
||
elif [ $status -eq 99 ]; then
|
||
echo "$post_run_msg [${yellow}SKIP$normal]"
|
||
else
|
||
echo "$post_run_msg [${red}FAIL$normal]"
|
||
echo "$log" | sed 's/^/ /'
|
||
exit "$status"
|
||
fi
|