Compare commits

...

5 Commits

Author SHA1 Message Date
regnat
a04a61bd46 tests: Fix the start of the daemon
- Make sure that it starts even without the `nix-command` xp feature
- Fail if it doesn’t manage to start

This fixes a 30s wait for every test in `init.sh` as the daemon couldn’t
start, but the code was just waiting 30s and continuing as if everything
was all right.
2022-02-28 17:00:15 +01:00
regnat
8daa04e265 Fix the logging of the tests time
Also log the time of `init.sh`
2022-02-28 17:00:15 +01:00
regnat
4d3e4ccdc5 Log the test times on nix build 2022-02-28 17:00:15 +01:00
regnat
5d13451935 Allow tracking the start and end time of tests 2022-02-28 17:00:15 +01:00
regnat
576c5951e4 Show the elapsed time for each test
To have an idea of what’s taking time
2022-02-28 17:00:15 +01:00
3 changed files with 24 additions and 6 deletions

View File

@@ -189,6 +189,8 @@
src = self;
TESTS_TIMER_LOG="${placeholder "out"}/testTime";
VERSION_SUFFIX = versionSuffix;
nativeBuildInputs = nativeBuildDeps;

View File

@@ -2,6 +2,11 @@
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=""
@@ -15,14 +20,19 @@ if [ -t 1 ]; then
normal=""
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]"
echo "$post_run_msg [${green}PASS$normal] in ${elapsed_time}s"
elif [ $status -eq 99 ]; then
echo "$post_run_msg [${yellow}SKIP$normal]"
echo "$post_run_msg [${yellow}SKIP$normal] after ${elapsed_time}s"
else
echo "$post_run_msg [${red}FAIL$normal]"
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"

View File

@@ -90,12 +90,18 @@ startDaemon() {
# Start the daemon, wait for the socket to appear. !!!
# nix-daemon should have an option to fork into the background.
rm -f $NIX_DAEMON_SOCKET_PATH
PATH=$DAEMON_PATH nix daemon &
PATH=$DAEMON_PATH nix-daemon&
pidDaemon=$!
for ((i = 0; i < 300; i++)); do
if [[ -S $NIX_DAEMON_SOCKET_PATH ]]; then break; fi
if [[ -S $NIX_DAEMON_SOCKET_PATH ]]; then
DAEMON_STARTED=1
break;
fi
sleep 0.1
done
pidDaemon=$!
if [[ -z ${DAEMON_STARTED+x} ]]; then
fail "Didnt manage to start the daemon"
fi
trap "killDaemon" EXIT
export NIX_REMOTE=daemon
}