From: Eric Wong Date: Mon, 4 Feb 2013 10:36:18 +0000 (+0000) Subject: tests: replace non-portable "date +%s" with ruby equivalent X-Git-Tag: v4.6.0~3 X-Git-Url: https://repo.or.cz/w/unicorn.git/commitdiff_plain/85223902e8229bd460ce0b4ad126f42b1db42a46 tests: replace non-portable "date +%s" with ruby equivalent "date +%s" is not in POSIX (it is in GNU, and at least FreeBSD 9.0, possibly earlier). The Ruby equivalent should be sufficiently portable between different Ruby versions. This change was automated via: perl -i -p -e 's/date \+%s/unix_time/' t/*.sh This is commit 0ba6fc3c30b9cf530faf7fcf5ce7be519ec13fe7 in rainbows.git --- diff --git a/t/t0004-heartbeat-timeout.sh b/t/t0004-heartbeat-timeout.sh index bf73ebea..3e373e97 100755 --- a/t/t0004-heartbeat-timeout.sh +++ b/t/t0004-heartbeat-timeout.sh @@ -23,9 +23,9 @@ t_begin "sleep for a bit, ensure worker PID does not change" && { t_begin "block the worker process to force it to die" && { rm $ok - t0=$(date +%s) + t0=$(unix_time) err="$(curl -sSf http://$listen/block-forever 2>&1 || > $ok)" - t1=$(date +%s) + t1=$(unix_time) elapsed=$(($t1 - $t0)) t_info "elapsed=$elapsed err=$err" test x"$err" != x"Should never get here" diff --git a/t/test-lib.sh b/t/test-lib.sh index 79791112..6d0fa226 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -32,6 +32,11 @@ wait_for_pid () { done } +# "unix_time" is not in POSIX, but in GNU, and FreeBSD 9.0 (possibly earlier) +unix_time () { + $RUBY -e 'puts Time.now.to_i' +} + # given a list of variable names, create temporary files and assign # the pathnames to those variables rtmpfiles () {