diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-10-24 12:20:58 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-24 12:20:58 -0700 |
commit | 2f8ed953decce975307a6c5b39330af816e184bc (patch) | |
tree | 07a56b46cf6aae765915d48cc1116c6ec20e7fee /t/test-lib.sh | |
parent | bd8912c86fc3ef617e72e4cf59fb308dc06563ba (diff) | |
download | rainbows-2f8ed953decce975307a6c5b39330af816e184bc.tar.gz |
Instead of sleeping and waiting for a PID file to appear, just use a named-pipe and block on it in the test scripts since we know Unicorn won't attempt to fork until sockets are already bound.
Diffstat (limited to 't/test-lib.sh')
-rwxr-xr-x | t/test-lib.sh | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/t/test-lib.sh b/t/test-lib.sh index b4ece30..d3815c4 100755 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -23,7 +23,7 @@ then t2???-thread-spawn-*.sh) model=ThreadSpawn ;; t3???-revactor-*.sh) model=Revactor ;; t4???-rev-*.sh) model=Rev ;; - *) model=any ;; + *) model=Base ;; esac fi @@ -126,6 +126,44 @@ check_stderr () { fi } +rainbows_setup () { + eval $(unused_listen) + rtmpfiles unicorn_config pid r_err r_out fifo tmp ok + cat > $unicorn_config <<EOF +listen "$listen" +pid "$pid" +stderr_path "$r_err" +stdout_path "$r_out" + +before_fork do |server, worker| + # test script will block while reading from $fifo, + # so notify the script on the first worker we spawn + # by opening the FIFO + if worker.nr == 0 + File.open("$fifo", "wb").close + end +end +EOF + { + if test $# -ge 1 + then + echo 'Rainbows! do' + echo " use :$1" + test $# -eq 2 && echo " worker_connections $2" + echo end + else + echo "Rainbows! { use :$model }" + fi + } >> $unicorn_config +} + +rainbows_wait_start () { + # "cat $fifo" will block until the before_fork hook is called in + # the Unicorn config file + test x = x"$(cat $fifo)" + rainbows_pid=$(cat $pid) +} + case $model in Rev) require_check rev Rev::VERSION ;; Revactor) require_check revactor Revactor::VERSION ;; |