eventmachine 1.0.0.beta.2-x86-mingw32 → 1.0.0.beta.3-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/.yardopts +3 -0
  2. data/Gemfile +1 -0
  3. data/eventmachine.gemspec +1 -3
  4. data/ext/cmain.cpp +4 -4
  5. data/ext/ed.cpp +13 -16
  6. data/ext/ed.h +9 -10
  7. data/ext/em.cpp +14 -24
  8. data/ext/eventmachine.h +2 -2
  9. data/ext/extconf.rb +1 -1
  10. data/ext/rubymain.cpp +8 -6
  11. data/lib/em/connection.rb +3 -1
  12. data/lib/em/pure_ruby.rb +17 -17
  13. data/lib/em/resolver.rb +186 -0
  14. data/lib/em/spawnable.rb +3 -7
  15. data/lib/em/version.rb +1 -1
  16. data/lib/eventmachine.rb +6 -4
  17. data/lib/jeventmachine.rb +1 -1
  18. data/tasks/package.rake +4 -1
  19. data/tasks/test.rake +1 -0
  20. data/tests/em_test_helper.rb +55 -0
  21. data/tests/test_attach.rb +46 -56
  22. data/tests/test_basic.rb +74 -96
  23. data/tests/test_channel.rb +2 -4
  24. data/tests/test_connection_count.rb +1 -3
  25. data/tests/test_defer.rb +13 -44
  26. data/tests/test_deferrable.rb +19 -19
  27. data/tests/test_epoll.rb +25 -55
  28. data/tests/test_error_handler.rb +10 -7
  29. data/tests/test_exc.rb +6 -33
  30. data/tests/test_file_watch.rb +51 -35
  31. data/tests/test_futures.rb +9 -37
  32. data/tests/test_get_sock_opt.rb +27 -20
  33. data/tests/test_handler_check.rb +1 -3
  34. data/tests/test_hc.rb +24 -59
  35. data/tests/test_httpclient.rb +27 -64
  36. data/tests/test_httpclient2.rb +1 -29
  37. data/tests/test_inactivity_timeout.rb +44 -40
  38. data/tests/test_kb.rb +26 -52
  39. data/tests/test_ltp.rb +23 -67
  40. data/tests/test_ltp2.rb +1 -30
  41. data/tests/test_next_tick.rb +1 -30
  42. data/tests/test_object_protocol.rb +8 -9
  43. data/tests/test_pause.rb +45 -37
  44. data/tests/test_pending_connect_timeout.rb +42 -38
  45. data/tests/test_process_watch.rb +1 -3
  46. data/tests/test_processes.rb +92 -110
  47. data/tests/test_proxy_connection.rb +128 -104
  48. data/tests/test_pure.rb +29 -75
  49. data/tests/test_queue.rb +2 -4
  50. data/tests/test_resolver.rb +55 -0
  51. data/tests/test_running.rb +1 -29
  52. data/tests/test_sasl.rb +7 -32
  53. data/tests/test_send_file.rb +162 -196
  54. data/tests/test_servers.rb +13 -56
  55. data/tests/test_smtpclient.rb +1 -29
  56. data/tests/test_smtpserver.rb +1 -29
  57. data/tests/test_spawn.rb +2 -31
  58. data/tests/test_ssl_args.rb +9 -10
  59. data/tests/test_ssl_methods.rb +1 -3
  60. data/tests/test_ssl_verify.rb +63 -63
  61. data/tests/test_tick_loop.rb +1 -1
  62. data/tests/test_timers.rb +52 -89
  63. data/tests/test_ud.rb +1 -29
  64. metadata +20 -10
  65. data/setup.rb +0 -1585
  66. data/tests/test_errors.rb +0 -82
  67. data/tests/testem.rb +0 -31
@@ -1,33 +1,4 @@
1
- # $Id$
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
 
@@ -1,33 +1,4 @@
1
- # $Id$
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
- $:.unshift "../lib"
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 Host, Port, Server
31
- EM.connect Host, Port, Client
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
@@ -1,30 +1,21 @@
1
- $:.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
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
- TestHost = "127.0.0.1"
8
- TestPort = 9070
9
-
10
- def setup
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
- def test_pause_resume
21
- test = self
22
- server = nil
13
+ def test_pause_resume
14
+ server = nil
23
15
 
24
- s_rx = c_rx = 0
16
+ s_rx = c_rx = 0
25
17
 
26
- EM.run do
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.add_timer(1) do
52
- test.assert_equal 1, s_rx
53
- test.assert_equal 0, c_rx
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
- # resume server, queued outgoing and incoming data will be flushed
57
- server.resume
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
- test.assert ! server.paused?
56
+ # resume server, queued outgoing and incoming data will be flushed
57
+ server.resume
60
58
 
61
- EM.add_timer(1) do
62
- test.assert server.paused?
63
- test.assert s_rx >= 2
64
- test.assert c_rx >= 1
65
- EM.stop_event_loop
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
- $:.unshift "../lib"
2
- require 'eventmachine'
3
- require 'test/unit'
1
+ require 'em_test_helper'
4
2
 
5
3
  class TestPendingConnectTimeout < Test::Unit::TestCase
6
4
 
7
- def test_default
8
- $timeout = nil
9
- EM.run {
10
- c = EM.connect("127.0.0.1", 54321)
11
- $timeout = c.pending_connect_timeout
12
- EM.stop
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
- module TimeoutHandler
31
- def unbind
32
- EM.stop
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
- def test_for_real
37
- $timeout = nil
38
- EM.run {
39
- EM.heartbeat_interval = 0.1
40
- $start = Time.now
41
- c = EM.connect("1.2.3.4", 54321, TimeoutHandler)
42
- c.pending_connect_timeout = 0.2
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
- assert_in_delta(0.2, (Time.now - $start), 0.1)
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
@@ -1,6 +1,4 @@
1
- $:.unshift "../lib"
2
- require 'eventmachine'
3
- require 'test/unit'
1
+ require 'em_test_helper'
4
2
 
5
3
  if EM.kqueue?
6
4
  class TestProcessWatch < Test::Unit::TestCase
@@ -1,128 +1,110 @@
1
- # $Id$
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
- # EM::DeferrableChildProcess is a sugaring of a common use-case
34
- # involving EM::popen.
35
- # Call the #open method on EM::DeferrableChildProcess, passing
36
- # a command-string. #open immediately returns an EM::Deferrable
37
- # object. It also schedules the forking of a child process, which
38
- # will execute the command passed to #open.
39
- # When the forked child terminates, the Deferrable will be signalled
40
- # and execute its callbacks, passing the data that the child process
41
- # wrote to stdout.
42
- #
43
- def test_deferrable_child_process
44
- ls = ""
45
- EM.run {
46
- d = EM::DeferrableChildProcess.open( "ls -ltr" )
47
- d.callback {|data_from_child|
48
- ls = data_from_child
49
- EM.stop
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
- assert( ls.length > 0)
53
- end
26
+ assert( ls.length > 0)
27
+ end
54
28
 
55
- def setup
56
- $out = nil
57
- $status = nil
58
- end
29
+ def setup
30
+ $out = nil
31
+ $status = nil
32
+ end
59
33
 
60
- def test_em_system
61
- EM.run{
62
- EM.system('ls'){ |out,status| $out, $status = out, status; EM.stop }
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
- assert( $out.length > 0 )
66
- assert_equal($status.exitstatus, 0)
67
- assert_equal($status.class, Process::Status)
68
- end
39
+ assert( $out.length > 0 )
40
+ assert_equal($status.exitstatus, 0)
41
+ assert_equal($status.class, Process::Status)
42
+ end
69
43
 
70
- def test_em_system_pid
71
- $pids = []
44
+ def test_em_system_pid
45
+ $pids = []
72
46
 
73
- EM.run{
74
- $pids << EM.system('echo hi', proc{ |out,status|$pids << status.pid; EM.stop })
75
- }
47
+ EM.run{
48
+ $pids << EM.system('echo hi', proc{ |out,status|$pids << status.pid; EM.stop })
49
+ }
76
50
 
77
- assert_equal $pids[0], $pids[1]
78
- end
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
- def test_em_system_with_proc
81
- EM.run{
82
- EM.system('ls', proc{ |out,status| $out, $status = out, status; EM.stop })
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
- assert( $out.length > 0 )
86
- assert_equal($status.exitstatus, 0)
87
- assert_equal($status.class, Process::Status)
88
- end
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
- def test_em_system_with_two_procs
91
- EM.run{
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
- def test_em_system_cmd_arguments
106
- EM.run{
107
- EM.system('sh', '--version', proc{ |process|
108
- }, proc{ |out,status|
109
- $out = out
110
- $status = status
111
- EM.stop
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
- def test_em_system_spaced_arguments
119
- EM.run{
120
- EM.system('ruby', '-e', 'puts "hello"', proc{ |out,status|
121
- $out = out
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
- assert_equal("hello\n", $out)
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