mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
set up load path properly for tests even when rubygems is enabled
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@707 19e92222-5c0b-0410-8929-a290d50e31e9
This commit is contained in:
parent
c77a757b47
commit
d665da08ba
2 changed files with 15 additions and 6 deletions
|
@ -21,8 +21,9 @@ end
|
|||
class WebServerTest < Test::Unit::TestCase
|
||||
|
||||
def setup
|
||||
@request = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\n\r\n"
|
||||
# we set num_processors=1 so that we can test the reaping code
|
||||
@valid_request = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\n\r\n"
|
||||
|
||||
# We set num_processors=1 so that we can test the reaping code
|
||||
@server = HttpServer.new("127.0.0.1", 9998, num_processors=1)
|
||||
@tester = TestHandler.new
|
||||
@server.register("/test", @tester)
|
||||
|
@ -48,24 +49,27 @@ class WebServerTest < Test::Unit::TestCase
|
|||
|
||||
while data = request.read(chunk)
|
||||
chunks_out += socket.write(data)
|
||||
puts "Chunks: #{chunks_out.inspect}"
|
||||
socket.flush
|
||||
sleep 0.2
|
||||
if close_after and chunks_out > close_after
|
||||
puts "** Closing write"
|
||||
socket.close_write
|
||||
sleep 1
|
||||
end
|
||||
end
|
||||
socket.write(" ") if RUBY_PLATFORM =~ /mingw|mswin|cygwin/
|
||||
socket.close
|
||||
puts "** Closing entire socket"
|
||||
end
|
||||
|
||||
def test_trickle_attack
|
||||
do_test(@request, 3)
|
||||
do_test(@valid_request, 3)
|
||||
end
|
||||
|
||||
def test_close_client
|
||||
assert_raises IOError do
|
||||
do_test(@request, 10, 20)
|
||||
do_test(@valid_request, 10, 20)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -88,8 +92,8 @@ class WebServerTest < Test::Unit::TestCase
|
|||
redirect_test_io do
|
||||
assert_raises Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNABORTED, Errno::EINVAL do
|
||||
tests = [
|
||||
Thread.new { do_test(@request, 1) },
|
||||
Thread.new { do_test(@request, 10) },
|
||||
Thread.new { do_test(@valid_request, 1) },
|
||||
Thread.new { do_test(@valid_request, 10) },
|
||||
]
|
||||
|
||||
tests.each {|t| t.join}
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
# Additional work donated by contributors. See http://mongrel.rubyforge.org/attributions.html
|
||||
# for more information.
|
||||
|
||||
HERE = File.dirname(__FILE__)
|
||||
%w(lib ext bin test).each do |dir|
|
||||
$LOAD_PATH.unshift "#{HERE}/../#{dir}"
|
||||
end
|
||||
|
||||
require 'rubygems'
|
||||
require 'test/unit'
|
||||
require 'net/http'
|
||||
|
|
Loading…
Add table
Reference in a new issue