mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 14:52:55 +00:00
8daa04e265
Also log the time of `init.sh`
39 lines
896 B
Bash
Executable File
39 lines
896 B
Bash
Executable File
#!/bin/sh
|
||
|
||
set -u
|
||
|
||
TESTS_TIMER_LOG=${TESTS_TIMER_LOG:-/dev/null}
|
||
|
||
start_time=$(date -u +%s)
|
||
echo "$(date -u +%s) $1 start" >> "$TESTS_TIMER_LOG"
|
||
|
||
red=""
|
||
green=""
|
||
yellow=""
|
||
normal=""
|
||
|
||
post_run_msg="ran test $1..."
|
||
if [ -t 1 ]; then
|
||
red="[31;1m"
|
||
green="[32;1m"
|
||
yellow="[33;1m"
|
||
normal="[m"
|
||
fi
|
||
(cd tests && env ${TESTS_ENVIRONMENT} init.sh 2>/dev/null > /dev/null)
|
||
|
||
log="$(cd $(dirname $1) && env ${TESTS_ENVIRONMENT} $(basename $1) 2>&1)"
|
||
status=$?
|
||
stop_time=$(date -u +%s)
|
||
elapsed_time=$(($stop_time-$start_time))
|
||
|
||
if [ $status -eq 0 ]; then
|
||
echo "$post_run_msg [${green}PASS$normal] in ${elapsed_time}s"
|
||
elif [ $status -eq 99 ]; then
|
||
echo "$post_run_msg [${yellow}SKIP$normal] after ${elapsed_time}s"
|
||
else
|
||
echo "$post_run_msg [${red}FAIL$normal] in ${elapsed_time}s"
|
||
echo "$log" | sed 's/^/ /'
|
||
exit "$status"
|
||
fi
|
||
echo "$(date -u +%s) $1 stop" >> "$TESTS_TIMER_LOG"
|