Permalink
Browse files

Fix integration test and cleanup 1.9.3 warnings

  • Loading branch information...
1 parent 98b0624 commit 49d27f888f7100db619699ef549fb0e44afdbf56 @evanphx evanphx committed Dec 7, 2011
Showing with 27 additions and 33 deletions.
  1. +7 −6 lib/puma/control_cli.rb
  2. +6 −6 test/test_app_status.rb
  3. +2 −10 test/test_http11.rb
  4. +11 −10 test/test_integration.rb
  5. +1 −1 test/test_ws.rb
@@ -11,8 +11,9 @@
module Puma
class ControlCLI
- def initialize(argv)
+ def initialize(argv, stdout=STDOUT)
@argv = argv
+ @stdout = stdout
end
def setup_options
@@ -80,7 +81,7 @@ def request(sock, url)
end
def command_pid
- puts "#{@state['pid']}"
+ @stdout.puts "#{@state['pid']}"
end
def command_stop
@@ -90,7 +91,7 @@ def command_stop
if body != '{ "status": "ok" }'
raise "Invalid response: '#{body}'"
else
- puts "Requested stop from server"
+ @stdout.puts "Requested stop from server"
end
end
@@ -101,7 +102,7 @@ def command_halt
if body != '{ "status": "ok" }'
raise "Invalid response: '#{body}'"
else
- puts "Requested halt from server"
+ @stdout.puts "Requested halt from server"
end
end
@@ -112,15 +113,15 @@ def command_restart
if body != '{ "status": "ok" }'
raise "Invalid response: '#{body}'"
else
- puts "Requested restart from server"
+ @stdout.puts "Requested restart from server"
end
end
def command_stats
sock = connect
body = request sock, "/stats"
- puts body
+ @stdout.puts body
end
end
end
@@ -32,7 +32,7 @@ def test_bad_token
env = { 'PATH_INFO' => "/whatever" }
- status, header, body = @app.call env
+ status, _, _ = @app.call env
assert_equal 403, status
end
@@ -45,23 +45,23 @@ def test_good_token
'QUERY_STRING' => "token=abcdef"
}
- status, header, body = @app.call env
+ status, _, _ = @app.call env
assert_equal 404, status
end
def test_unsupported
env = { 'PATH_INFO' => "/not-real" }
- status, header, body = @app.call env
+ status, _, _ = @app.call env
assert_equal 404, status
end
def test_stop
env = { 'PATH_INFO' => "/stop" }
- status, header, body = @app.call env
+ status, _ , body = @app.call env
assert_equal :stop, @server.status
assert_equal 200, status
@@ -71,7 +71,7 @@ def test_stop
def test_halt
env = { 'PATH_INFO' => "/halt" }
- status, header, body = @app.call env
+ status, _ , body = @app.call env
assert_equal :halt, @server.status
assert_equal 200, status
@@ -84,7 +84,7 @@ def test_stats
@server.backlog = 1
@server.running = 9
- status, header, body = @app.call env
+ status, _ , body = @app.call env
assert_equal 200, status
assert_equal ['{ "backlog": 1, "running": 9 }'], body
View
@@ -37,14 +37,6 @@ def test_parse_dumbfuck_headers
assert_equal should_be_good.length, nread
assert parser.finished?
assert !parser.error?
-
- nasty_pound_header = "GET / HTTP/1.1\r\nX-SSL-Bullshit: -----BEGIN CERTIFICATE-----\r\n\tMIIFbTCCBFWgAwIBAgICH4cwDQYJKoZIhvcNAQEFBQAwcDELMAkGA1UEBhMCVUsx\r\n\tETAPBgNVBAoTCGVTY2llbmNlMRIwEAYDVQQLEwlBdXRob3JpdHkxCzAJBgNVBAMT\r\n\tAkNBMS0wKwYJKoZIhvcNAQkBFh5jYS1vcGVyYXRvckBncmlkLXN1cHBvcnQuYWMu\r\n\tdWswHhcNMDYwNzI3MTQxMzI4WhcNMDcwNzI3MTQxMzI4WjBbMQswCQYDVQQGEwJV\r\n\tSzERMA8GA1UEChMIZVNjaWVuY2UxEzARBgNVBAsTCk1hbmNoZXN0ZXIxCzAJBgNV\r\n\tBAcTmrsogriqMWLAk1DMRcwFQYDVQQDEw5taWNoYWVsIHBhcmQYJKoZIhvcNAQEB\r\n\tBQADggEPADCCAQoCggEBANPEQBgl1IaKdSS1TbhF3hEXSl72G9J+WC/1R64fAcEF\r\n\tW51rEyFYiIeZGx/BVzwXbeBoNUK41OK65sxGuflMo5gLflbwJtHBRIEKAfVVp3YR\r\n\tgW7cMA/s/XKgL1GEC7rQw8lIZT8RApukCGqOVHSi/F1SiFlPDxuDfmdiNzL31+sL\r\n\t0iwHDdNkGjy5pyBSB8Y79dsSJtCW/iaLB0/n8Sj7HgvvZJ7x0fr+RQjYOUUfrePP\r\n\tu2MSpFyf+9B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ugvzEbyv4Olnsr8hbxF1MbKZoQxUZtMVu29wjfXk\r\n\thTeApBv7eaKCWpSp7MCbvgzm74izKhu3vlDk9w6qVrxePfGgpKPqfHiOoGhFnbTK\r\n\twTC6o2xq5y0qZ03JonF7OJspEd3I5zKY3E+ov7/ZhW6DqT8UFvsAdjvQbXyhV8Eu\r\n\tYhixw1aKEPzNjNowuIseVogKOLXxWI5vAi5HgXdS0/ES5gDGsABo4fqovUKlgop3\r\n\tRA==\r\n\t-----END CERTIFICATE-----\r\n\r\n"
- parser = HttpParser.new
- req = {}
- #nread = parser.execute(req, nasty_pound_header, 0)
- #assert_equal nasty_pound_header.length, nread
- #assert parser.finished?
- #assert !parser.error?
end
def test_parse_error
@@ -54,8 +46,8 @@ def test_parse_error
error = false
begin
- nread = parser.execute(req, bad_http, 0)
- rescue => details
+ parser.execute(req, bad_http, 0)
+ rescue
error = true
end
@@ -2,6 +2,9 @@
require 'rubygems'
require 'socket'
+require 'puma/cli'
+require 'puma/control_cli'
+
class TestIntegration < Test::Unit::TestCase
def setup
@state_path = "test/test_puma.state"
@@ -16,15 +19,13 @@ def teardown
end
def test_stop_via_pumactl
- status = nil
-
- io = IO.popen "#{Gem.ruby} -Ilib bin/puma -S #{@state_path} -b unix://#{@bind_path} --control unix://#{@control_path} test/hello.ru 2>&1", "r"
+ sin = StringIO.new
+ sout = StringIO.new
- line = nil
+ cli = Puma::CLI.new %W!-q -S #{@state_path} -b unix://#{@bind_path} --control unix://#{@control_path} test/hello.ru!, sin, sout
- until /Use Ctrl-C to stop/ =~ line.to_s
- line = io.gets
- raise "error" unless line
+ t = Thread.new do
+ cli.run
end
sleep 1
@@ -33,10 +34,10 @@ def test_stop_via_pumactl
s << "GET / HTTP/1.0\r\n\r\n"
assert_equal "Hello World", s.read.split("\r\n").last
- `#{Gem.ruby} -Ilib bin/pumactl -S #{@state_path} stop 2>&1`
+ ccli = Puma::ControlCLI.new %W!-S #{@state_path} stop!, sout
- pid, status = Process.wait2(io.pid)
+ ccli.run
- assert_equal 0, status.to_i
+ assert_kind_of Thread, t.join(1), "server didn't stop"
end
end
View
@@ -90,7 +90,7 @@ def test_header_is_too_long
def test_file_streamed_request
body = "a" * (Puma::Const::MAX_BODY * 2)
long = "GET /test HTTP/1.1\r\nContent-length: #{body.length}\r\n\r\n" + body
- do_test(long, Puma::Const::CHUNK_SIZE * 2 -400)
+ do_test(long, (Puma::Const::CHUNK_SIZE * 2) - 400)
end
end

0 comments on commit 49d27f8

Please sign in to comment.