summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-02-04 12:39:09 +0000
committerEric Wong <normalperson@yhbt.net>2013-02-04 12:39:09 +0000
commit9cd8554749a9f120b010c93933d09d2dd27b1280 (patch)
treecc085e5218ecc342a35420d2bb137dcb42403506
parent2a2163594ea2b515e98fbe9f909bcf90e4c35fe8 (diff)
On FreeBSD 9.0, "wc -l" emits leading whitespace, so
filter it through tr -d '[:space:]' to eliminate it.
-rwxr-xr-xt/t0000-http-basic.sh2
-rwxr-xr-xt/t0004-heartbeat-timeout.sh2
-rwxr-xr-xt/t0100-rack-input-tests.sh14
-rwxr-xr-xt/t9000-preread-input.sh4
-rw-r--r--t/test-lib.sh5
5 files changed, 16 insertions, 11 deletions
diff --git a/t/t0000-http-basic.sh b/t/t0000-http-basic.sh
index 01ead95..8ab58ac 100755
--- a/t/t0000-http-basic.sh
+++ b/t/t0000-http-basic.sh
@@ -26,7 +26,7 @@ t_begin "HTTP/0.9 request should not return headers" && {
 }
 
 t_begin "env.inspect should've put everything on one line" && {
-        test 1 -eq $(wc -l < $tmp)
+        test 1 -eq $(count_lines < $tmp)
 }
 
 t_begin "no headers in output" && {
diff --git a/t/t0004-heartbeat-timeout.sh b/t/t0004-heartbeat-timeout.sh
index 3e373e9..2965283 100755
--- a/t/t0004-heartbeat-timeout.sh
+++ b/t/t0004-heartbeat-timeout.sh
@@ -34,7 +34,7 @@ t_begin "block the worker process to force it to die" && {
 
 t_begin "ensure worker was killed" && {
         test -e $ok
-        test 1 -eq $(grep timeout $r_err | grep killing | wc -l)
+        test 1 -eq $(grep timeout $r_err | grep killing | count_lines)
 }
 
 t_begin "ensure timeout took at least 3 seconds" && {
diff --git a/t/t0100-rack-input-tests.sh b/t/t0100-rack-input-tests.sh
index 873f15c..ee7a437 100755
--- a/t/t0100-rack-input-tests.sh
+++ b/t/t0100-rack-input-tests.sh
@@ -24,7 +24,7 @@ t_begin "corked identity request" && {
                 wait
                 echo ok > $ok
         ) | ( sleep 1 && socat - TCP4:$listen > $fifo )
-        test 1 -eq $(grep $blob_sha1 $tmp |wc -l)
+        test 1 -eq $(grep $blob_sha1 $tmp |count_lines)
         test x"$(cat $ok)" = xok
 }
 
@@ -36,7 +36,7 @@ t_begin "corked chunked request" && {
                 wait
                 echo ok > $ok
         ) | ( sleep 1 && socat - TCP4:$listen > $fifo )
-        test 1 -eq $(grep $blob_sha1 $tmp |wc -l)
+        test 1 -eq $(grep $blob_sha1 $tmp |count_lines)
         test x"$(cat $ok)" = xok
 }
 
@@ -50,7 +50,7 @@ t_begin "corked identity request (input#size first)" && {
                 wait
                 echo ok > $ok
         ) | ( sleep 1 && socat - TCP4:$listen > $fifo )
-        test 1 -eq $(grep $blob_sha1 $tmp |wc -l)
+        test 1 -eq $(grep $blob_sha1 $tmp |count_lines)
         test x"$(cat $ok)" = xok
 }
 
@@ -64,7 +64,7 @@ t_begin "corked identity request (input#rewind first)" && {
                 wait
                 echo ok > $ok
         ) | ( sleep 1 && socat - TCP4:$listen > $fifo )
-        test 1 -eq $(grep $blob_sha1 $tmp |wc -l)
+        test 1 -eq $(grep $blob_sha1 $tmp |count_lines)
         test x"$(cat $ok)" = xok
 }
 
@@ -81,8 +81,8 @@ t_begin "corked chunked request (input#size first)" && {
                 wait
                 echo ok > $ok
         ) | ( sleep 1 && socat - TCP4:$listen > $fifo )
-        test 1 -eq $(grep $blob_sha1 $tmp |wc -l)
-        test 1 -eq $(grep $blob_sha1 $tmp |wc -l)
+        test 1 -eq $(grep $blob_sha1 $tmp |count_lines)
+        test 1 -eq $(grep $blob_sha1 $tmp |count_lines)
         test x"$(cat $ok)" = xok
 }
 
@@ -99,7 +99,7 @@ t_begin "corked chunked request (input#rewind first)" && {
                 wait
                 echo ok > $ok
         ) | ( sleep 1 && socat - TCP4:$listen > $fifo )
-        test 1 -eq $(grep $blob_sha1 $tmp |wc -l)
+        test 1 -eq $(grep $blob_sha1 $tmp |count_lines)
         test x"$(cat $ok)" = xok
 }
 
diff --git a/t/t9000-preread-input.sh b/t/t9000-preread-input.sh
index b9da05e..d6c73ab 100755
--- a/t/t9000-preread-input.sh
+++ b/t/t9000-preread-input.sh
@@ -26,7 +26,7 @@ t_begin "sha1 matches" && {
 }
 
 t_begin "app only dispatched twice" && {
-        test 2 -eq "$(grep 'app dispatch:' < $r_err | wc -l )"
+        test 2 -eq "$(grep 'app dispatch:' < $r_err | count_lines )"
 }
 
 t_begin "aborted chunked request" && {
@@ -38,7 +38,7 @@ t_begin "aborted chunked request" && {
 }
 
 t_begin "app only dispatched twice" && {
-        test 2 -eq "$(grep 'app dispatch:' < $r_err | wc -l )"
+        test 2 -eq "$(grep 'app dispatch:' < $r_err | count_lines )"
 }
 
 t_begin "killing succeeds" && {
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 2b93576..28d6a88 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -37,6 +37,11 @@ unix_time () {
         $RUBY -e 'puts Time.now.to_i'
 }
 
+# "wc -l" outputs leading whitespace on *BSDs, filter it out for portability
+count_lines () {
+        wc -l | tr -d '[:space:]'
+}
+
 # "wc -c" outputs leading whitespace on *BSDs, filter it out for portability
 count_bytes () {
         wc -c | tr -d '[:space:]'