Merge pull request #6179 from NixOS/properly-start-the-daemon-in-tests

tests: Fix the start of the daemon
This commit is contained in:
Théophane Hufschmitt 2022-02-28 19:23:50 +01:00 committed by GitHub
commit 1c985428c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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