Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #237 from nahi/test-warning-cleanups

Warning cleanups for rake test
  • Loading branch information...
commit 232605cd885b867ef189566e623f8dd6f078038d 2 parents eeb7f12 + 918a901
@tmm1 tmm1 authored
View
6 lib/em/completion.rb
@@ -248,7 +248,7 @@ def completion_states
def timeout(time, *args)
cancel_timeout
@timeout_timer = EM::Timer.new(time) do
- fail *args unless completed?
+ fail(*args) unless completed?
end
end
@@ -287,7 +287,7 @@ def execute_callbacks
# Iterate all callbacks for a given state, and remove then call them.
def execute_state_callbacks(state)
while callback = @callbacks[state].shift
- callback.call *value
+ callback.call(*value)
end
end
@@ -300,4 +300,4 @@ def clear_dead_callbacks
end
end
end
-end
+end
View
4 lib/em/protocols/httpclient.rb
@@ -64,7 +64,7 @@ class HttpClient < Connection
MaxPostContentLength = 20 * 1024 * 1024
def initialize
- STDERR.puts "HttpClient is deprecated and will be removed. EM-Http-Request should be used instead."
+ warn "HttpClient is deprecated and will be removed. EM-Http-Request should be used instead."
end
# @param args [Hash] The request arguments
@@ -276,4 +276,4 @@ def unbind
end
end
-end
+end
View
2  lib/em/protocols/httpclient2.rb
@@ -44,7 +44,7 @@ class HttpClient2 < Connection
include LineText2
def initialize
- STDERR.puts "HttpClient2 is deprecated and will be removed. EM-Http-Request should be used instead."
+ warn "HttpClient2 is deprecated and will be removed. EM-Http-Request should be used instead."
@authorization = nil
@closed = nil
View
2  lib/em/protocols/smtpserver.rb
@@ -357,7 +357,7 @@ def process_auth str
def process_auth_line(line)
plain = line.unpack("m").first
- discard,user,psw = plain.split("\000")
+ _,user,psw = plain.split("\000")
if receive_plain_auth user,psw
send_data "235 authentication ok\r\n"
@state << :auth
View
2  lib/em/pure_ruby.rb
@@ -448,7 +448,7 @@ def initialize io
s = Socket.for_fd(@io.fileno)
s.fcntl( Fcntl::F_SETFL, Fcntl::O_NONBLOCK )
rescue Errno::EINVAL, Errno::EBADF
- STDERR.puts "Serious error: unable to set descriptor non-blocking"
+ warn "Serious error: unable to set descriptor non-blocking"
end
end
# TODO, should set CLOEXEC on Unix?
View
13 tests/em_test_helper.rb
@@ -3,7 +3,7 @@
require 'rbconfig'
require 'socket'
-Test::Unit::TestCase.class_eval do
+class Test::Unit::TestCase
class EMTestTimeout < StandardError ; end
def setup_timeout(timeout = TIMEOUT_INTERVAL)
@@ -38,7 +38,7 @@ def exception_class
module PlatformHelper
# http://blog.emptyway.com/2009/11/03/proper-way-to-detect-windows-platform-in-ruby/
def windows?
- Config::CONFIG['host_os'] =~ /mswin|mingw/
+ RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
end
# http://stackoverflow.com/questions/1342535/how-can-i-tell-if-im-running-from-jruby-vs-ruby/1685970#1685970
@@ -52,4 +52,13 @@ def jruby?
# Tests run significantly slower on windows. YMMV
TIMEOUT_INTERVAL = windows? ? 1 : 0.25
+
+ def silent
+ backup, $VERBOSE = $VERBOSE, nil
+ begin
+ yield
+ ensure
+ $VERBOSE = backup
+ end
+ end
end
View
4 tests/test_completion.rb
@@ -158,7 +158,7 @@ def test_timeout
args = [1, 2, 3]
EM.run do
completion.timeout(0.0001, *args)
- completion.errback { |*args| results << args }
+ completion.errback { |*errargs| results << errargs }
completion.completion { EM.stop }
EM.add_timer(0.1) { flunk 'test timed out' }
end
@@ -174,4 +174,4 @@ def test_timeout_gets_cancelled
end
assert_equal [], results
end
-end
+end
View
4 tests/test_epoll.rb
@@ -49,7 +49,7 @@ def test_rlimit
# XXX this test causes all sort of weird issues on OSX (when run as part of the suite)
def _test_descriptors
EM.epoll
- s = EM.set_descriptor_table_size 60000
+ EM.set_descriptor_table_size 60000
EM.run {
EM.start_server "127.0.0.1", 9800, TestEchoServer
$n = 0
@@ -101,7 +101,7 @@ def test_datagrams
def _test_unix_domain
fn = "/tmp/xxx.chain"
EM.epoll
- s = EM.set_descriptor_table_size 60000
+ EM.set_descriptor_table_size 60000
EM.run {
# The pure-Ruby version won't let us open the socket if the node already exists.
# Not sure, that actually may be correct and the compiled version is wrong.
View
18 tests/test_httpclient.rb
@@ -16,7 +16,7 @@ def teardown
def test_http_client
ok = false
EM.run {
- c = EM::P::HttpClient.send :request, :host => "www.google.com", :port => 80
+ c = silent { EM::P::HttpClient.send :request, :host => "www.google.com", :port => 80 }
c.callback {
ok = true
EM.stop
@@ -31,7 +31,7 @@ def test_http_client
def test_http_client_1
ok = false
EM.run {
- c = EM::P::HttpClient.send :request, :host => "www.google.com", :port => 80
+ c = silent { EM::P::HttpClient.send :request, :host => "www.google.com", :port => 80 }
c.callback {ok = true; EM.stop}
c.errback {EM.stop}
}
@@ -43,7 +43,7 @@ def test_http_client_1
def test_http_client_2
ok = false
EM.run {
- c = EM::P::HttpClient.send :request, :host => "www.google.com", :port => 80
+ c = silent { EM::P::HttpClient.send :request, :host => "www.google.com", :port => 80 }
c.callback {|result|
ok = true;
EM.stop
@@ -75,7 +75,7 @@ def test_http_empty_content
ok = false
EM.run {
EM.start_server "127.0.0.1", 9701, EmptyContent
- c = EM::P::HttpClient.send :request, :host => "127.0.0.1", :port => 9701
+ c = silent { EM::P::HttpClient.send :request, :host => "127.0.0.1", :port => 9701 }
c.callback {|result|
ok = true
EM.stop
@@ -134,14 +134,14 @@ def test_post
EM.run {
EM.start_server Localhost, Localport, PostContent
setup_timeout(2)
- c = EM::P::HttpClient.request(
+ c = silent { EM::P::HttpClient.request(
:host=>Localhost,
:port=>Localport,
:method=>:post,
:request=>"/aaa",
:content=>"XYZ",
:content_type=>"text/plain"
- )
+ )}
c.callback {|r|
response = r
EM.stop
@@ -158,7 +158,7 @@ def test_post
def test_cookie
ok = false
EM.run {
- c = EM::Protocols::HttpClient.send :request, :host => "www.google.com", :port => 80, :cookie=>"aaa=bbb"
+ c = silent { EM::Protocols::HttpClient.send :request, :host => "www.google.com", :port => 80, :cookie=>"aaa=bbb" }
c.callback {|result|
ok = true;
EM.stop
@@ -173,11 +173,11 @@ def test_cookie
def test_version_1_0
ok = false
EM.run {
- c = EM::P::HttpClient.request(
+ c = silent { EM::P::HttpClient.request(
:host => "www.google.com",
:port => 80,
:version => "1.0"
- )
+ )}
c.callback {|result|
ok = true;
EM.stop
View
20 tests/test_httpclient2.rb
@@ -22,8 +22,10 @@ class TestServer < EM::Connection
def test_connect
EM.run {
EM.start_server Localhost, Localport, TestServer
- http1 = EM::P::HttpClient2.connect Localhost, Localport
- http2 = EM::P::HttpClient2.connect( :host=>Localhost, :port=>Localport )
+ silent do
+ EM::P::HttpClient2.connect Localhost, Localport
+ EM::P::HttpClient2.connect( :host=>Localhost, :port=>Localport )
+ end
EM.stop
}
end
@@ -33,7 +35,7 @@ def test_bad_port
EM.run {
EM.start_server Localhost, Localport, TestServer
assert_raises( ArgumentError ) {
- EM::P::HttpClient2.connect Localhost, "xxx"
+ silent { EM::P::HttpClient2.connect Localhost, "xxx" }
}
EM.stop
}
@@ -42,7 +44,7 @@ def test_bad_port
def test_bad_server
err = nil
EM.run {
- http = EM::P::HttpClient2.connect Localhost, 9999
+ http = silent { EM::P::HttpClient2.connect Localhost, 9999 }
d = http.get "/"
d.errback { err = true; d.internal_error; EM.stop }
}
@@ -52,7 +54,7 @@ def test_bad_server
def test_get
content = nil
EM.run {
- http = EM::P::HttpClient2.connect "google.com", 80
+ http = silent { EM::P::HttpClient2.connect "google.com", 80 }
d = http.get "/"
d.callback {
content = d.content
@@ -68,7 +70,7 @@ def test_get
def _test_get_multiple
content = nil
EM.run {
- http = EM::P::HttpClient2.connect "google.com", 80
+ http = silent { EM::P::HttpClient2.connect "google.com", 80 }
d = http.get "/"
d.callback {
e = http.get "/"
@@ -84,7 +86,7 @@ def _test_get_multiple
def test_get_pipeline
headers, headers2 = nil, nil
EM.run {
- http = EM::P::HttpClient2.connect "google.com", 80
+ http = silent { EM::P::HttpClient2.connect "google.com", 80 }
d = http.get("/")
d.callback {
headers = d.headers
@@ -104,7 +106,7 @@ def test_get_pipeline
def test_authheader
EM.run {
EM.start_server Localhost, Localport, TestServer
- http = EM::P::HttpClient2.connect Localhost, 18842
+ http = silent { EM::P::HttpClient2.connect Localhost, 18842 }
d = http.get :url=>"/", :authorization=>"Basic xxx"
d.callback {EM.stop}
d.errback {EM.stop}
@@ -114,7 +116,7 @@ def test_authheader
def test_https_get
d = nil
EM.run {
- http = EM::P::HttpClient2.connect :host => 'www.apple.com', :port => 443, :ssl => true
+ http = silent { EM::P::HttpClient2.connect :host => 'www.apple.com', :port => 443, :ssl => true }
d = http.get "/"
d.callback {
EM.stop
View
12 tests/test_ltp.rb
@@ -87,12 +87,8 @@ def receive_binary_data text
def test_lines_and_text
output = ''
- lines_received = []
- text_received = []
EM.run {
- EM.start_server( "127.0.0.1", @port, LineAndTextTest ) do |conn|
- conn.instance_eval "@lines = lines_received; @text = text_received"
- end
+ EM.start_server( "127.0.0.1", @port, LineAndTextTest )
setup_timeout
EM.connect "127.0.0.1", @port, StopClient do |c|
@@ -125,12 +121,8 @@ def receive_binary_data text
def test_binary_text
output = ''
- lines_received = []
- text_received = []
EM.run {
- EM.start_server( "127.0.0.1", @port, BinaryTextTest ) do |conn|
- conn.instance_eval "@lines = lines_received; @text = text_received"
- end
+ EM.start_server( "127.0.0.1", @port, BinaryTextTest )
setup_timeout
EM.connect "127.0.0.1", @port, StopClient do |c|
View
4 tests/test_processes.rb
@@ -78,7 +78,7 @@ def test_em_system_with_two_procs
def test_em_system_cmd_arguments
EM.run{
- EM.system('sh', '--version', proc{ |process|
+ EM.system('echo', '1', '2', 'version', proc{ |process|
}, proc{ |out,status|
$out = out
$status = status
@@ -86,7 +86,7 @@ def test_em_system_cmd_arguments
})
}
- assert_match(/version/i, $out)
+ assert_match(/1 2 version/i, $out)
end
def test_em_system_spaced_arguments
View
4 tests/test_threaded_resource.rb
@@ -42,7 +42,7 @@ def test_dispatch_threading
resource.dispatch do |o|
o[:dispatch_thread] = Thread.current
end
- assert_not_equal Thread.current, object[:dispatch_thread]
+ assert_not_equal main, object[:dispatch_thread]
end
def test_shutdown
@@ -50,4 +50,4 @@ def test_shutdown
# NOT an api that will be maintained.
assert !resource.shutdown.alive?
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.