···1+preCheckHooks+=('memcachedStart')
2+postCheckHooks+=('memcachedStop')
3+4+5+memcachedStart() {
6+ if [[ "${memcachedTestPort:-}" == "" ]]; then
7+ memcachedTestPort=11211
8+ fi
9+10+ echo 'starting memcached'
11+12+ # Note about Darwin: unless the output is redirected, the parent process becomes launchd instead of bash.
13+ # This would leave the memcached process running in case of a test failure (the postCheckHook would not be executed),
14+ # hanging the Nix build forever.
15+ @memcached@ -p "$memcachedTestPort" >/dev/null 2>&1 &
16+ MEMCACHED_PID=$!
17+18+ echo 'waiting for memcached to be ready'
19+ while ! (echo 'quit' | @nc@ localhost "$memcachedTestPort") ; do
20+ sleep 1
21+ done
22+}
23+24+memcachedStop() {
25+ echo 'stopping memcached'
26+ kill "$MEMCACHED_PID"
27+}