about summary refs log tree commit homepage
path: root/test/test_helper.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-03-18 01:01:25 -0700
committerEric Wong <normalperson@yhbt.net>2009-03-18 01:10:11 -0700
commit2373b663049df69a168f1e876e817a49d8ed8a7b (patch)
tree22bf1ca52b3e8d85ffb442f218d461508fc4c71b /test/test_helper.rb
parentec8972dbe267dc0d21cd780c41f362a6580a4a89 (diff)
downloadunicorn-2373b663049df69a168f1e876e817a49d8ed8a7b.tar.gz
Despite reading numerous articles and inspecting the 1.9.1-p0 C
source, I will never trust that we're always handling
encoding-aware IO objects correctly.  Thus this new test uses
UNIX shell utilities that should always operate on files/sockets
on a byte-level.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 'test/test_helper.rb')
-rw-r--r--test/test_helper.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb
index f809af3..4243606 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -41,7 +41,18 @@ def redirect_test_io
     STDOUT.reopen(orig_out)
   end
 end
-    
+
+# which(1) exit codes cannot be trusted on some systems
+# We use UNIX shell utilities in some tests because we don't trust
+# ourselves to write Ruby 100% correctly :)
+def which(bin)
+  ex = ENV['PATH'].split(/:/).detect do |x|
+    x << "/#{bin}"
+    File.executable?(x)
+  end or warn "`#{bin}' not found in PATH=#{ENV['PATH']}"
+  ex
+end
+
 # Either takes a string to do a get request against, or a tuple of [URI, HTTP] where
 # HTTP is some kind of Net::HTTP request object (POST, HEAD, etc.)
 def hit(uris)