aboutsummaryrefslogtreecommitdiff
path: root/tests/common.sh.in
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2022-03-10 15:48:14 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2022-03-10 15:48:14 +0000
commit8ba089597fa19bfd49ba5f22a5e821740ca4eb5d (patch)
treeb4f2299b9c973ef7636f8ce1bab0299dee4cc389 /tests/common.sh.in
parent13b6b645897fd2edaa0f09fa48d6fe8dd6287b55 (diff)
parent4d98143914120d0163f5c50f30ce8a5289433f8f (diff)
Merge remote-tracking branch 'upstream/master' into path-info
Diffstat (limited to 'tests/common.sh.in')
-rw-r--r--tests/common.sh.in39
1 files changed, 25 insertions, 14 deletions
diff --git a/tests/common.sh.in b/tests/common.sh.in
index 7daab2460..8ce28d318 100644
--- a/tests/common.sh.in
+++ b/tests/common.sh.in
@@ -36,8 +36,9 @@ export PATH=@bindir@:$PATH
if [[ -n "${NIX_CLIENT_PACKAGE:-}" ]]; then
export PATH="$NIX_CLIENT_PACKAGE/bin":$PATH
fi
+DAEMON_PATH="$PATH"
if [[ -n "${NIX_DAEMON_PACKAGE:-}" ]]; then
- export NIX_DAEMON_COMMAND="$NIX_DAEMON_PACKAGE/bin/nix-daemon"
+ DAEMON_PATH="${NIX_DAEMON_PACKAGE}/bin:$DAEMON_PATH"
fi
coreutils=@coreutils@
@@ -86,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
- ${NIX_DAEMON_COMMAND:-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
}
@@ -126,7 +132,7 @@ isDaemonNewer () {
[[ -n "${NIX_DAEMON_PACKAGE:-}" ]] || return 0
local requiredVersion="$1"
local daemonVersion=$($NIX_DAEMON_PACKAGE/bin/nix-daemon --version | cut -d' ' -f3)
- return [[ $(nix eval --expr "builtins.compareVersions ''$daemonVersion'' ''2.4''") -ge 0 ]]
+ [[ $(nix eval --expr "builtins.compareVersions ''$daemonVersion'' ''$requiredVersion''") -ge 0 ]]
}
requireDaemonNewerThan () {
@@ -166,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