Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tests: "wc -l" portability for *BSDs

On FreeBSD 9.0, "wc -l" emits leading whitespace, so
filter it through tr -d '[:space:]' to eliminate it.
  • Loading branch information...
commit 9cd8554749a9f120b010c93933d09d2dd27b1280 1 parent 2a21635
Eric Wong authored
View
2  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" && {
View
2  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" && {
View
14 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
}
View
4 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" && {
View
5 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:]'
Please sign in to comment.
Something went wrong with that request. Please try again.