test: Print test status after each test
@@ -6,11 +6,12 @@ texec() {
./testenv_exec.sh "$(pgrep -P "$finit_ppid")" "$@"
}
-fg_red='31'
-fg_green='32'
-fg_yellow='33'
+color_reset='\e[0m'
+fg_red='\e[1;31m'
+fg_green='\e[1;32m'
+fg_yellow='\e[1;33m'
log() {
- printf "< $TEST_DIR > \e[1;%dm%s\e[0m %s\n" "$1" "$2" "$3"
+ printf "< $TEST_DIR > %b%b%b %s\n" "$1" "$2" "$color_reset" "$3"
}
assert() {
@@ -28,13 +29,25 @@ say() {
}
teardown() {
+ test_status="$?"
+ log "$color_reset" '--' ''
+ if [ "$test_status" -eq 0 ]; then
+ log "$fg_green" 'TEST PASS' ''
+ else
+ log "$fg_red" 'TEST FAIL' ''
+ fi
texec kill 1
wait
}
+TEST_DIR=$(dirname "$1")
+
trap teardown EXIT
+log "$color_reset" 'Test start' ''
+log "$color_reset" '--' ''
+
# Setup
./testenv_start.sh finit &
finit_ppid=$!
@@ -47,6 +60,4 @@ done
texec cat /dev/tty0 &
sleep 1
-TEST_DIR=$(dirname "$1")
-
. "$1"
