aboutsummaryrefslogtreecommitdiff
path: root/tests/common.sh.in
diff options
context:
space:
mode:
Diffstat (limited to 'tests/common.sh.in')
-rw-r--r--tests/common.sh.in34
1 files changed, 22 insertions, 12 deletions
diff --git a/tests/common.sh.in b/tests/common.sh.in
index 61abab1d7..8ce28d318 100644
--- a/tests/common.sh.in
+++ b/tests/common.sh.in
@@ -87,26 +87,31 @@ startDaemon() {
if [[ "$NIX_REMOTE" == daemon ]]; then
return
fi
- # Start the daemon, wait for the socket to appear. !!!
- # ‘nix-daemon’ should have an option to fork into the background.
+ # Start the daemon, wait for the socket to appear.
rm -f $NIX_DAEMON_SOCKET_PATH
- PATH=$DAEMON_PATH nix daemon &
- for ((i = 0; i < 30; i++)); do
- if [[ -S $NIX_DAEMON_SOCKET_PATH ]]; then break; fi
- sleep 1
- done
+ PATH=$DAEMON_PATH nix-daemon&
pidDaemon=$!
+ for ((i = 0; i < 300; i++)); do
+ if [[ -S $NIX_DAEMON_SOCKET_PATH ]]; then
+ DAEMON_STARTED=1
+ break;
+ fi
+ sleep 0.1
+ done
+ if [[ -z ${DAEMON_STARTED+x} ]]; then
+ fail "Didn’t manage to start the daemon"
+ fi
trap "killDaemon" EXIT
export NIX_REMOTE=daemon
}
killDaemon() {
kill $pidDaemon
- for i in {0.10}; do
- kill -0 $pidDaemon || break
- sleep 1
+ for i in {0..100}; do
+ kill -0 $pidDaemon 2> /dev/null || break
+ sleep 0.1
done
- kill -9 $pidDaemon || true
+ kill -9 $pidDaemon 2> /dev/null || true
wait $pidDaemon || true
trap "" EXIT
}
@@ -167,10 +172,15 @@ needLocalStore() {
}
# Just to make it easy to find which tests should be fixed
-buggyNeedLocalStore () {
+buggyNeedLocalStore() {
needLocalStore
}
+enableFeatures() {
+ local features="$1"
+ sed -i 's/experimental-features .*/& '"$features"'/' "$NIX_CONF_DIR"/nix.conf
+}
+
set -x
if [[ -n "${NIX_DAEMON_PACKAGE:-}" ]]; then