eventmachine 1.0.0.beta.2-x86-mswin32-60 → 1.0.0.beta.3-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +3 -0
- data/Gemfile +1 -0
- data/eventmachine.gemspec +1 -3
- data/ext/cmain.cpp +4 -4
- data/ext/ed.cpp +13 -16
- data/ext/ed.h +9 -10
- data/ext/em.cpp +14 -24
- data/ext/eventmachine.h +2 -2
- data/ext/extconf.rb +1 -1
- data/ext/rubymain.cpp +8 -6
- data/lib/em/connection.rb +3 -1
- data/lib/em/pure_ruby.rb +17 -17
- data/lib/em/resolver.rb +186 -0
- data/lib/em/spawnable.rb +3 -7
- data/lib/em/version.rb +1 -1
- data/lib/eventmachine.rb +6 -4
- data/lib/jeventmachine.rb +1 -1
- data/tasks/package.rake +4 -1
- data/tasks/test.rake +1 -0
- data/tests/em_test_helper.rb +55 -0
- data/tests/test_attach.rb +46 -56
- data/tests/test_basic.rb +74 -96
- data/tests/test_channel.rb +2 -4
- data/tests/test_connection_count.rb +1 -3
- data/tests/test_defer.rb +13 -44
- data/tests/test_deferrable.rb +19 -19
- data/tests/test_epoll.rb +25 -55
- data/tests/test_error_handler.rb +10 -7
- data/tests/test_exc.rb +6 -33
- data/tests/test_file_watch.rb +51 -35
- data/tests/test_futures.rb +9 -37
- data/tests/test_get_sock_opt.rb +27 -20
- data/tests/test_handler_check.rb +1 -3
- data/tests/test_hc.rb +24 -59
- data/tests/test_httpclient.rb +27 -64
- data/tests/test_httpclient2.rb +1 -29
- data/tests/test_inactivity_timeout.rb +44 -40
- data/tests/test_kb.rb +26 -52
- data/tests/test_ltp.rb +23 -67
- data/tests/test_ltp2.rb +1 -30
- data/tests/test_next_tick.rb +1 -30
- data/tests/test_object_protocol.rb +8 -9
- data/tests/test_pause.rb +45 -37
- data/tests/test_pending_connect_timeout.rb +42 -38
- data/tests/test_process_watch.rb +1 -3
- data/tests/test_processes.rb +92 -110
- data/tests/test_proxy_connection.rb +128 -104
- data/tests/test_pure.rb +29 -75
- data/tests/test_queue.rb +2 -4
- data/tests/test_resolver.rb +55 -0
- data/tests/test_running.rb +1 -29
- data/tests/test_sasl.rb +7 -32
- data/tests/test_send_file.rb +162 -196
- data/tests/test_servers.rb +13 -56
- data/tests/test_smtpclient.rb +1 -29
- data/tests/test_smtpserver.rb +1 -29
- data/tests/test_spawn.rb +2 -31
- data/tests/test_ssl_args.rb +9 -10
- data/tests/test_ssl_methods.rb +1 -3
- data/tests/test_ssl_verify.rb +63 -63
- data/tests/test_tick_loop.rb +1 -1
- data/tests/test_timers.rb +52 -89
- data/tests/test_ud.rb +1 -29
- metadata +20 -10
- data/setup.rb +0 -1585
- data/tests/test_errors.rb +0 -82
- data/tests/testem.rb +0 -31
data/tests/test_ltp2.rb
CHANGED
@@ -1,33 +1,4 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
|
-
# Homepage:: http://rubyeventmachine.com
|
5
|
-
# Date:: 8 April 2006
|
6
|
-
#
|
7
|
-
# See EventMachine and EventMachine::Connection for documentation and
|
8
|
-
# usage examples.
|
9
|
-
#
|
10
|
-
#----------------------------------------------------------------------------
|
11
|
-
#
|
12
|
-
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
13
|
-
# Gmail: blackhedd
|
14
|
-
#
|
15
|
-
# This program is free software; you can redistribute it and/or modify
|
16
|
-
# it under the terms of either: 1) the GNU General Public License
|
17
|
-
# as published by the Free Software Foundation; either version 2 of the
|
18
|
-
# License, or (at your option) any later version; or 2) Ruby's License.
|
19
|
-
#
|
20
|
-
# See the file COPYING for complete licensing information.
|
21
|
-
#
|
22
|
-
#---------------------------------------------------------------------------
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
|
28
|
-
$:.unshift "../lib"
|
29
|
-
require 'eventmachine'
|
30
|
-
require 'test/unit'
|
1
|
+
require 'em_test_helper'
|
31
2
|
|
32
3
|
# TODO!!! Need tests for overlength headers and text bodies.
|
33
4
|
|
data/tests/test_next_tick.rb
CHANGED
@@ -1,33 +1,4 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
|
-
# Homepage:: http://rubyeventmachine.com
|
5
|
-
# Date:: 8 April 2006
|
6
|
-
#
|
7
|
-
# See EventMachine and EventMachine::Connection for documentation and
|
8
|
-
# usage examples.
|
9
|
-
#
|
10
|
-
#----------------------------------------------------------------------------
|
11
|
-
#
|
12
|
-
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
13
|
-
# Gmail: blackhedd
|
14
|
-
#
|
15
|
-
# This program is free software; you can redistribute it and/or modify
|
16
|
-
# it under the terms of either: 1) the GNU General Public License
|
17
|
-
# as published by the Free Software Foundation; either version 2 of the
|
18
|
-
# License, or (at your option) any later version; or 2) Ruby's License.
|
19
|
-
#
|
20
|
-
# See the file COPYING for complete licensing information.
|
21
|
-
#
|
22
|
-
#---------------------------------------------------------------------------
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
|
28
|
-
$:.unshift "../lib"
|
29
|
-
require 'eventmachine'
|
30
|
-
require 'test/unit'
|
1
|
+
require 'em_test_helper'
|
31
2
|
|
32
3
|
class TestNextTick < Test::Unit::TestCase
|
33
4
|
|
@@ -1,11 +1,6 @@
|
|
1
|
-
|
2
|
-
require 'eventmachine'
|
3
|
-
require 'test/unit'
|
1
|
+
require 'em_test_helper'
|
4
2
|
|
5
3
|
class TestObjectProtocol < Test::Unit::TestCase
|
6
|
-
Host = "127.0.0.1"
|
7
|
-
Port = 9550
|
8
|
-
|
9
4
|
module Server
|
10
5
|
include EM::P::ObjectProtocol
|
11
6
|
def post_init
|
@@ -25,13 +20,17 @@ class TestObjectProtocol < Test::Unit::TestCase
|
|
25
20
|
end
|
26
21
|
end
|
27
22
|
|
23
|
+
def setup
|
24
|
+
@port = next_port
|
25
|
+
end
|
26
|
+
|
28
27
|
def test_send_receive
|
29
28
|
EM.run{
|
30
|
-
EM.start_server
|
31
|
-
EM.connect
|
29
|
+
EM.start_server "127.0.0.1", @port, Server
|
30
|
+
EM.connect "127.0.0.1", @port, Client
|
32
31
|
}
|
33
32
|
|
34
33
|
assert($client == {:hello=>'world'})
|
35
34
|
assert($server == {'you_said'=>{:hello=>'world'}})
|
36
35
|
end
|
37
|
-
end
|
36
|
+
end
|
data/tests/test_pause.rb
CHANGED
@@ -1,30 +1,21 @@
|
|
1
|
-
|
2
|
-
require 'eventmachine'
|
3
|
-
require 'socket'
|
4
|
-
require 'test/unit'
|
1
|
+
require 'em_test_helper'
|
5
2
|
|
6
3
|
class TestPause < Test::Unit::TestCase
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
assert(!EM.reactor_running?)
|
12
|
-
end
|
13
|
-
|
14
|
-
def teardown
|
15
|
-
assert(!EM.reactor_running?)
|
16
|
-
end
|
4
|
+
if EM.respond_to? :pause_connection
|
5
|
+
def setup
|
6
|
+
@port = next_port
|
7
|
+
end
|
17
8
|
|
18
|
-
|
9
|
+
def teardown
|
10
|
+
assert(!EM.reactor_running?)
|
11
|
+
end
|
19
12
|
|
20
|
-
|
21
|
-
|
22
|
-
server = nil
|
13
|
+
def test_pause_resume
|
14
|
+
server = nil
|
23
15
|
|
24
|
-
|
16
|
+
s_rx = c_rx = 0
|
25
17
|
|
26
|
-
|
27
|
-
EM.start_server TestHost, TestPort, Module.new {
|
18
|
+
test_server = Module.new do
|
28
19
|
define_method :post_init do
|
29
20
|
server = self
|
30
21
|
end
|
@@ -39,32 +30,49 @@ class TestPause < Test::Unit::TestCase
|
|
39
30
|
# be sent and no more incoming data will be received
|
40
31
|
pause
|
41
32
|
end
|
42
|
-
|
33
|
+
end
|
34
|
+
|
35
|
+
test_client = Module.new do
|
36
|
+
def post_init
|
37
|
+
EM.add_periodic_timer(0.01) do
|
38
|
+
send_data 'hello'
|
39
|
+
end
|
40
|
+
end
|
43
41
|
|
44
|
-
c = EM.connect TestHost, TestPort, Module.new {
|
45
42
|
define_method :receive_data do |data|
|
46
43
|
c_rx += 1
|
47
44
|
end
|
48
|
-
|
49
|
-
EM.add_periodic_timer(0.01) { c.send_data 'hi' }
|
45
|
+
end
|
50
46
|
|
51
|
-
EM.
|
52
|
-
|
53
|
-
|
54
|
-
test.assert server.paused?
|
47
|
+
EM.run do
|
48
|
+
EM.start_server "127.0.0.1", @port, test_server
|
49
|
+
EM.connect "127.0.0.1", @port, test_client
|
55
50
|
|
56
|
-
|
57
|
-
|
51
|
+
EM.add_timer(0.05) do
|
52
|
+
assert_equal 1, s_rx
|
53
|
+
assert_equal 0, c_rx
|
54
|
+
assert server.paused?
|
58
55
|
|
59
|
-
|
56
|
+
# resume server, queued outgoing and incoming data will be flushed
|
57
|
+
server.resume
|
60
58
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
assert !server.paused?
|
60
|
+
|
61
|
+
EM.add_timer(0.05) do
|
62
|
+
assert server.paused?
|
63
|
+
assert s_rx > 1
|
64
|
+
assert c_rx > 0
|
65
|
+
EM.stop
|
66
|
+
end
|
66
67
|
end
|
67
68
|
end
|
68
69
|
end
|
70
|
+
else
|
71
|
+
warn "EM.pause_connection not implemented, skipping tests in #{__FILE__}"
|
72
|
+
|
73
|
+
# Because some rubies will complain if a TestCase class has no tests
|
74
|
+
def test_em_pause_connection_not_implemented
|
75
|
+
assert true
|
76
|
+
end
|
69
77
|
end
|
70
78
|
end
|
@@ -1,48 +1,52 @@
|
|
1
|
-
|
2
|
-
require 'eventmachine'
|
3
|
-
require 'test/unit'
|
1
|
+
require 'em_test_helper'
|
4
2
|
|
5
3
|
class TestPendingConnectTimeout < Test::Unit::TestCase
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
assert_equal(20.0, $timeout)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_set_and_get
|
19
|
-
$timeout = nil
|
20
|
-
EM.run {
|
21
|
-
c = EM.connect("1.2.3.4", 54321)
|
22
|
-
c.pending_connect_timeout = 2.5
|
23
|
-
$timeout = c.pending_connect_timeout
|
24
|
-
EM.stop
|
25
|
-
}
|
26
|
-
|
27
|
-
assert_equal(2.5, $timeout)
|
28
|
-
end
|
5
|
+
if EM.respond_to? :get_pending_connect_timeout
|
6
|
+
def test_default
|
7
|
+
EM.run {
|
8
|
+
c = EM.connect("127.0.0.1", 54321)
|
9
|
+
assert_equal 20.0, c.pending_connect_timeout
|
10
|
+
EM.stop
|
11
|
+
}
|
12
|
+
end
|
29
13
|
|
30
|
-
|
31
|
-
|
32
|
-
|
14
|
+
def test_set_and_get
|
15
|
+
EM.run {
|
16
|
+
c = EM.connect("127.0.0.1", 54321)
|
17
|
+
c.pending_connect_timeout = 2.5
|
18
|
+
assert_equal 2.5, c.pending_connect_timeout
|
19
|
+
EM.stop
|
20
|
+
}
|
33
21
|
end
|
34
|
-
end
|
35
22
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
23
|
+
def test_for_real
|
24
|
+
start, finish = nil
|
25
|
+
|
26
|
+
timeout_handler = Module.new do
|
27
|
+
define_method :unbind do
|
28
|
+
finish = Time.now
|
29
|
+
EM.stop
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
EM.run {
|
34
|
+
setup_timeout
|
35
|
+
EM.heartbeat_interval = 0.1
|
36
|
+
start = Time.now
|
37
|
+
c = EM.connect("1.2.3.4", 54321, timeout_handler)
|
38
|
+
c.pending_connect_timeout = 0.2
|
39
|
+
}
|
40
|
+
|
41
|
+
assert_in_delta(0.2, (finish - start), 0.1)
|
42
|
+
end
|
43
|
+
else
|
44
|
+
warn "EM.pending_connect_timeout not implemented, skipping tests in #{__FILE__}"
|
44
45
|
|
45
|
-
|
46
|
+
# Because some rubies will complain if a TestCase class has no tests
|
47
|
+
def test_em_pending_connect_timeout_not_implemented
|
48
|
+
assert true
|
49
|
+
end
|
46
50
|
end
|
47
51
|
|
48
52
|
end
|
data/tests/test_process_watch.rb
CHANGED
data/tests/test_processes.rb
CHANGED
@@ -1,128 +1,110 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# Author:: Francis Cianfrocca (gmail: blackhedd)
|
4
|
-
# Homepage:: http://rubyeventmachine.com
|
5
|
-
# Date:: 8 April 2006
|
6
|
-
#
|
7
|
-
# See EventMachine and EventMachine::Connection for documentation and
|
8
|
-
# usage examples.
|
9
|
-
#
|
10
|
-
#----------------------------------------------------------------------------
|
11
|
-
#
|
12
|
-
# Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
|
13
|
-
# Gmail: blackhedd
|
14
|
-
#
|
15
|
-
# This program is free software; you can redistribute it and/or modify
|
16
|
-
# it under the terms of either: 1) the GNU General Public License
|
17
|
-
# as published by the Free Software Foundation; either version 2 of the
|
18
|
-
# License, or (at your option) any later version; or 2) Ruby's License.
|
19
|
-
#
|
20
|
-
# See the file COPYING for complete licensing information.
|
21
|
-
#
|
22
|
-
#---------------------------------------------------------------------------
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
|
27
|
-
$:.unshift "../lib"
|
28
|
-
require 'eventmachine'
|
29
|
-
require 'test/unit'
|
1
|
+
require 'em_test_helper'
|
30
2
|
|
31
3
|
class TestProcesses < Test::Unit::TestCase
|
32
4
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
5
|
+
if !windows? && !jruby?
|
6
|
+
|
7
|
+
# EM::DeferrableChildProcess is a sugaring of a common use-case
|
8
|
+
# involving EM::popen.
|
9
|
+
# Call the #open method on EM::DeferrableChildProcess, passing
|
10
|
+
# a command-string. #open immediately returns an EM::Deferrable
|
11
|
+
# object. It also schedules the forking of a child process, which
|
12
|
+
# will execute the command passed to #open.
|
13
|
+
# When the forked child terminates, the Deferrable will be signalled
|
14
|
+
# and execute its callbacks, passing the data that the child process
|
15
|
+
# wrote to stdout.
|
16
|
+
#
|
17
|
+
def test_deferrable_child_process
|
18
|
+
ls = ""
|
19
|
+
EM.run {
|
20
|
+
d = EM::DeferrableChildProcess.open( "ls -ltr" )
|
21
|
+
d.callback {|data_from_child|
|
22
|
+
ls = data_from_child
|
23
|
+
EM.stop
|
24
|
+
}
|
50
25
|
}
|
51
|
-
|
52
|
-
|
53
|
-
end
|
26
|
+
assert( ls.length > 0)
|
27
|
+
end
|
54
28
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
29
|
+
def setup
|
30
|
+
$out = nil
|
31
|
+
$status = nil
|
32
|
+
end
|
59
33
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
34
|
+
def test_em_system
|
35
|
+
EM.run{
|
36
|
+
EM.system('ls'){ |out,status| $out, $status = out, status; EM.stop }
|
37
|
+
}
|
64
38
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
39
|
+
assert( $out.length > 0 )
|
40
|
+
assert_equal($status.exitstatus, 0)
|
41
|
+
assert_equal($status.class, Process::Status)
|
42
|
+
end
|
69
43
|
|
70
|
-
|
71
|
-
|
44
|
+
def test_em_system_pid
|
45
|
+
$pids = []
|
72
46
|
|
73
|
-
|
74
|
-
|
75
|
-
|
47
|
+
EM.run{
|
48
|
+
$pids << EM.system('echo hi', proc{ |out,status|$pids << status.pid; EM.stop })
|
49
|
+
}
|
76
50
|
|
77
|
-
|
78
|
-
|
51
|
+
assert_equal $pids[0], $pids[1]
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_em_system_with_proc
|
55
|
+
EM.run{
|
56
|
+
EM.system('ls', proc{ |out,status| $out, $status = out, status; EM.stop })
|
57
|
+
}
|
79
58
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
59
|
+
assert( $out.length > 0 )
|
60
|
+
assert_equal($status.exitstatus, 0)
|
61
|
+
assert_equal($status.class, Process::Status)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_em_system_with_two_procs
|
65
|
+
EM.run{
|
66
|
+
EM.system('sh', proc{ |process|
|
67
|
+
process.send_data("echo hello\n")
|
68
|
+
process.send_data("exit\n")
|
69
|
+
}, proc{ |out,status|
|
70
|
+
$out = out
|
71
|
+
$status = status
|
72
|
+
EM.stop
|
73
|
+
})
|
74
|
+
}
|
84
75
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
76
|
+
assert_equal("hello\n", $out)
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_em_system_cmd_arguments
|
80
|
+
EM.run{
|
81
|
+
EM.system('sh', '--version', proc{ |process|
|
82
|
+
}, proc{ |out,status|
|
83
|
+
$out = out
|
84
|
+
$status = status
|
85
|
+
EM.stop
|
86
|
+
})
|
87
|
+
}
|
89
88
|
|
90
|
-
|
91
|
-
|
92
|
-
EM.system('sh', proc{ |process|
|
93
|
-
process.send_data("echo hello\n")
|
94
|
-
process.send_data("exit\n")
|
95
|
-
}, proc{ |out,status|
|
96
|
-
$out = out
|
97
|
-
$status = status
|
98
|
-
EM.stop
|
99
|
-
})
|
100
|
-
}
|
101
|
-
|
102
|
-
assert_equal("hello\n", $out)
|
103
|
-
end
|
89
|
+
assert_match(/version/i, $out)
|
90
|
+
end
|
104
91
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
})
|
113
|
-
}
|
114
|
-
|
115
|
-
assert_match(/version/i, $out)
|
116
|
-
end
|
92
|
+
def test_em_system_spaced_arguments
|
93
|
+
EM.run{
|
94
|
+
EM.system('ruby', '-e', 'puts "hello"', proc{ |out,status|
|
95
|
+
$out = out
|
96
|
+
EM.stop
|
97
|
+
})
|
98
|
+
}
|
117
99
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
EM.stop
|
123
|
-
})
|
124
|
-
}
|
100
|
+
assert_equal("hello\n", $out)
|
101
|
+
end
|
102
|
+
else
|
103
|
+
warn "EM.popen not implemented, skipping tests in #{__FILE__}"
|
125
104
|
|
126
|
-
|
105
|
+
# Because some rubies will complain if a TestCase class has no tests
|
106
|
+
def test_em_popen_unsupported
|
107
|
+
assert true
|
108
|
+
end
|
127
109
|
end
|
128
110
|
end
|