diff options
author | Eric Wong <normalperson@yhbt.net> | 2012-02-17 21:44:31 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2012-02-17 22:50:19 +0000 |
commit | fd2428590505ffa3e14dfa6df55520bbecff6231 (patch) | |
tree | 7d7bf76fb6e9942c010662afb7760c11d3329924 /test/test_helper.rb | |
parent | 6b47e8517ba04da10719b0fbfd9c6ccb7010d806 (diff) | |
download | cmogstored-fd2428590505ffa3e14dfa6df55520bbecff6231.tar.gz |
Also we'll have better splitting of test cases into fast/slow portions.
Diffstat (limited to 'test/test_helper.rb')
-rw-r--r-- | test/test_helper.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb index 501f86a..a040054 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -12,3 +12,25 @@ $stderr.sync = $stdout.sync = Thread.abort_on_exception = true TEST_HOST = ENV["TEST_HOST"] || (RUBY_PLATFORM =~ /linux/ ? "127.#{rand(256)}.#{rand(256)}.#{rand(256)}" : "127.0.0.1") + +EPOCH = "Thu, 01 Jan 1970 00:00:00 GMT" + +def replace_dates!(header) + rv = header.gsub!(/: \w{3}, \d{2} \w{3} \d{4} \d{2}:\d{2}:\d{2} GMT\r\n/, + ": #{EPOCH}\r\n") + assert(rv, header) +end + +def t_yield + sleep 0.015 +end + +def get_client(tries = 300) + begin + c = TCPSocket.new(@host, @port) + @to_close << c + return c + rescue + t_yield + end while (tries-=1) > 0 +end |