summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-10-18 05:42:56 (GMT)
committerEric Wong <normalperson@yhbt.net>2009-10-18 05:42:56 (GMT)
commit95417ca711a75612da86a25acd20134efdbc0e67 (patch)
tree653f9486283cc2ff2c8abc5835291ed05652c4c6
parentb68b53c0323f691dbc412fa5ff581ff0b9a7ef1f (diff)
downloadrainbows-95417ca711a75612da86a25acd20134efdbc0e67.tar.gz
tests: add unbuffered tee(1)-like helper
Buffering enabled in tee(1) was making tests more difficult to debug.
-rw-r--r--t/GNUmakefile2
-rw-r--r--t/README2
-rwxr-xr-xt/bin/utee12
3 files changed, 14 insertions, 2 deletions
diff --git a/t/GNUmakefile b/t/GNUmakefile
index 934c179..7eac0d5 100644
--- a/t/GNUmakefile
+++ b/t/GNUmakefile
@@ -44,7 +44,7 @@ else
SH_TEST_OPTS += -x
endif
quiet_pre = @echo '* $@';
- quiet_post = 2>&1 | tee $(t_log); exit $$(cat $(t_code))
+ quiet_post = 2>&1 | ./bin/utee $(t_log); exit $$(cat $(t_code))
pfx = $@
endif
diff --git a/t/README b/t/README
index 4745b6d..a019dbf 100644
--- a/t/README
+++ b/t/README
@@ -14,7 +14,7 @@ comfortable writing integration tests with.
* {GNU make}[http://www.gnu.org/software/make/]
* {socat}[http://www.dest-unreach.org/socat/]
* {curl}[http://curl.haxx.se/]
-* standard UNIX shell utilities (Bourne sh, awk, sed, grep, tee, ...)
+* standard UNIX shell utilities (Bourne sh, awk, sed, grep, ...)
We do not use bashisms or any non-portable, non-POSIX constructs
in our shell code. We use the "pipefail" option if available and
diff --git a/t/bin/utee b/t/bin/utee
new file mode 100755
index 0000000..e48f307
--- /dev/null
+++ b/t/bin/utee
@@ -0,0 +1,12 @@
+#!/usr/bin/env ruby
+# tee(1) as distributed on most(all?) systems is buffered in luserspace
+# this only does unbuffered writes (with line-buffered input) to make
+# test output appear in real-time
+# -*- encoding: binary -*-
+$stdin.binmode
+$stdout.binmode
+fp = File.open(ARGV.shift, "wb")
+$stdin.each_line do |line|
+ fp.syswrite line
+ $stdout.syswrite line
+end