···11+preCheckHooks+=('memcachedStart')
22+postCheckHooks+=('memcachedStop')
33+44+55+memcachedStart() {
66+ if [[ "${memcachedTestPort:-}" == "" ]]; then
77+ memcachedTestPort=11211
88+ fi
99+1010+ echo 'starting memcached'
1111+1212+ # Note about Darwin: unless the output is redirected, the parent process becomes launchd instead of bash.
1313+ # This would leave the memcached process running in case of a test failure (the postCheckHook would not be executed),
1414+ # hanging the Nix build forever.
1515+ @memcached@ -p "$memcachedTestPort" >/dev/null 2>&1 &
1616+ MEMCACHED_PID=$!
1717+1818+ echo 'waiting for memcached to be ready'
1919+ while ! (echo 'quit' | @nc@ localhost "$memcachedTestPort") ; do
2020+ sleep 1
2121+ done
2222+}
2323+2424+memcachedStop() {
2525+ echo 'stopping memcached'
2626+ kill "$MEMCACHED_PID"
2727+}