···11+preCheckHooks+=('redisStart')
22+postCheckHooks+=('redisStop')
33+44+55+redisStart() {
66+ if [[ "${redisTestPort:-}" == "" ]]; then
77+ redisTestPort=6379
88+ fi
99+1010+ if [[ "${REDIS_SOCKET:-}" == "" ]]; then
1111+ mkdir -p "$NIX_BUILD_TOP/run/"
1212+ REDIS_SOCKET="$NIX_BUILD_TOP/run/redis.sock"
1313+ fi
1414+ export REDIS_SOCKET
1515+1616+ echo 'starting redis'
1717+1818+ # Note about Darwin: unless the output is redirected, the parent process becomes launchd instead of bash.
1919+ # This would leave the Redis process running in case of a test failure (the postCheckHook would not be executed),
2020+ # hanging the Nix build forever.
2121+ @server@ --unixsocket "$REDIS_SOCKET" --port "$redisTestPort" > /dev/null 2>&1 &
2222+ REDIS_PID=$!
2323+2424+ echo 'waiting for redis to be ready'
2525+ while ! @cli@ --scan -s "$REDIS_SOCKET" ; do
2626+ sleep 1
2727+ done
2828+}
2929+3030+redisStop() {
3131+ echo 'stopping redis'
3232+ kill "$REDIS_PID"
3333+}