Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Move to Rake::TestTask, turn on warnings, and cleanup warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
raggi committed Oct 4, 2009
1 parent 677362b commit 0e7d8b8
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 15 deletions.
6 changes: 3 additions & 3 deletions lib/em/connection.rb
Expand Up @@ -53,9 +53,9 @@ def self.new(sig, *args) #:nodoc:
def initialize(*args) #:nodoc:
end

def associate_callback_target(sig) #:nodoc:
# no-op for the time being, to match similar no-op in rubymain.cpp
end
# def associate_callback_target(sig) #:nodoc:
# # no-op for the time being, to match similar no-op in rubymain.cpp
# end

# EventMachine::Connection#post_init is called by the event loop
# immediately after the network connection has been established,
Expand Down
5 changes: 5 additions & 0 deletions lib/em/deferrable.rb
Expand Up @@ -42,6 +42,7 @@ module Deferrable
#
def callback &block
return unless block
@deferred_status ||= :unknown
if @deferred_status == :succeeded
block.call(*@deferred_args)
elsif @deferred_status != :failed
Expand All @@ -59,6 +60,7 @@ def callback &block
#
def errback &block
return unless block
@deferred_status ||= :unknown
if @deferred_status == :failed
block.call(*@deferred_args)
elsif @deferred_status != :succeeded
Expand Down Expand Up @@ -121,6 +123,8 @@ def errback &block
#
def set_deferred_status status, *args
cancel_timeout
@errbacks ||= nil
@callbacks ||= nil
@deferred_status = status
@deferred_args = args
case @deferred_status
Expand Down Expand Up @@ -155,6 +159,7 @@ def timeout seconds
# Cancels an outstanding timeout if any. Undoes the action of #timeout.
#
def cancel_timeout
@deferred_timeout ||= nil
if @deferred_timeout
@deferred_timeout.cancel
@deferred_timeout = nil
Expand Down
1 change: 1 addition & 0 deletions lib/em/delegate_connection.rb
Expand Up @@ -33,6 +33,7 @@ class DelegateConnection < Connection
def initialize(delegate)
@delegate = delegate
@delegate.init(self)
@ip, @port = nil, nil
end

# Retreive the connections ip and port from the reactor.
Expand Down
8 changes: 8 additions & 0 deletions lib/em/protocols/httpclient2.rb
Expand Up @@ -40,6 +40,12 @@ module Protocols
# }
class HttpClient2 < Connection
include LineText2

def initialize
@authorization = nil
@closed = nil
@requests = nil
end

class Request # :nodoc:
include Deferrable
Expand All @@ -57,6 +63,8 @@ def initialize conn, args
@header_lines = []
@headers = {}
@blanks = 0
@chunk_trailer = nil
@chunking = nil
end

def send_request
Expand Down
1 change: 0 additions & 1 deletion lib/em/protocols/line_and_text.rb
Expand Up @@ -23,7 +23,6 @@
#
#
#
require File.dirname(__FILE__) + '/../buftok'

module EventMachine
module Protocols
Expand Down
1 change: 1 addition & 0 deletions lib/em/protocols/linetext2.rb
Expand Up @@ -132,6 +132,7 @@ def set_binary_mode size=nil
# when in sized text mode. User overrides of #receive_binary_data need to
# be aware that they may get a short buffer.
def unbind
@lt2_mode ||= nil
if @lt2_mode == :text and @lt2_textpos > 0
receive_binary_data @lt2_textbuffer.join
end
Expand Down
7 changes: 7 additions & 0 deletions lib/em/protocols/smtpclient.rb
Expand Up @@ -66,6 +66,13 @@ module Protocols
class SmtpClient < Connection
include EventMachine::Deferrable
include EventMachine::Protocols::LineText2

def initialize
@succeeded = nil
@responder = nil
@code = nil
@msg = nil
end

# :host => required String
# a string containing the IP address or host name of the SMTP server to connect to.
Expand Down
2 changes: 1 addition & 1 deletion lib/em/server.rb
Expand Up @@ -48,7 +48,7 @@ def set_delegate(delegate)
when Module
[Class.new(EM::Connection) { include delegate }]
when Proc
[Module.new &delegate]
[Module.new(&delegate)]
# when nil # TODO
# LoggerConnection
else
Expand Down
1 change: 1 addition & 0 deletions lib/em/timers.rb
Expand Up @@ -31,6 +31,7 @@ class PeriodicTimer
def initialize interval, callback=nil, &block
@interval = interval
@code = callback || block
@cancelled = false
schedule
end

Expand Down
4 changes: 4 additions & 0 deletions lib/eventmachine.rb
Expand Up @@ -191,6 +191,10 @@ class <<self
attr_reader :reactor_thread
end
@next_tick_mutex = Mutex.new
@reactor_running = false
@next_tick_queue = nil
@threadpool = nil


# EventMachine::run initializes and runs an event loop.
# This method only returns if user-callback code calls stop_event_loop.
Expand Down
9 changes: 4 additions & 5 deletions tasks/tests.rake
Expand Up @@ -22,11 +22,10 @@ def run_tests t, libr = :cascade, test_files="test_*.rb"
runner.run(suite)
end

desc "Run tests for #{Spec.name}."
task :test do |t|
# run_tests t
# Rake +/ friends leave threads, etc, less stable test runs.
ruby "-Ilib -Iext -Iext/fastfilereader -Ijava tests/testem.rb #{'-v' if ENV['VERBOSE']}"
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.pattern = 'tests/**/test_*.rb'
t.warning = true
end

namespace :test do
Expand Down
21 changes: 16 additions & 5 deletions tests/test_ssl_args.rb
Expand Up @@ -9,18 +9,29 @@ def self._set_mocks
class <<self
alias set_tls_parms_old set_tls_parms
alias start_tls_old start_tls
def set_tls_parms *args; end
def start_tls *args; end
begin
old, $VERBOSE = $VERBOSE, nil
def set_tls_parms *args; end
def start_tls *args; end
ensure
$VERBOSE = old
end
end
end

def self._clear_mocks
class <<self
alias set_tls_parms set_tls_parms_old
alias start_tls start_tls_old
begin
old, $VERBOSE = $VERBOSE, nil
alias set_tls_parms set_tls_parms_old
alias start_tls start_tls_old
ensure
$VERBOSE = old
end
end
end
end



class TestSslArgs < Test::Unit::TestCase
Expand Down

0 comments on commit 0e7d8b8

Please sign in to comment.