eventmachine 1.0.0.beta.2-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +16 -0
- data/Gemfile +1 -0
- data/README +81 -0
- data/Rakefile +11 -0
- data/docs/COPYING +60 -0
- data/docs/ChangeLog +211 -0
- data/docs/DEFERRABLES +246 -0
- data/docs/EPOLL +141 -0
- data/docs/GNU +281 -0
- data/docs/INSTALL +13 -0
- data/docs/KEYBOARD +42 -0
- data/docs/LEGAL +25 -0
- data/docs/LIGHTWEIGHT_CONCURRENCY +130 -0
- data/docs/PURE_RUBY +75 -0
- data/docs/RELEASE_NOTES +94 -0
- data/docs/SMTP +4 -0
- data/docs/SPAWNED_PROCESSES +148 -0
- data/docs/TODO +8 -0
- data/eventmachine.gemspec +33 -0
- data/examples/ex_channel.rb +43 -0
- data/examples/ex_queue.rb +2 -0
- data/examples/ex_tick_loop_array.rb +15 -0
- data/examples/ex_tick_loop_counter.rb +32 -0
- data/examples/helper.rb +2 -0
- data/ext/binder.cpp +124 -0
- data/ext/binder.h +46 -0
- data/ext/cmain.cpp +838 -0
- data/ext/ed.cpp +1884 -0
- data/ext/ed.h +418 -0
- data/ext/em.cpp +2348 -0
- data/ext/em.h +228 -0
- data/ext/eventmachine.h +123 -0
- data/ext/extconf.rb +157 -0
- data/ext/fastfilereader/extconf.rb +85 -0
- data/ext/fastfilereader/mapper.cpp +214 -0
- data/ext/fastfilereader/mapper.h +59 -0
- data/ext/fastfilereader/rubymain.cpp +127 -0
- data/ext/kb.cpp +79 -0
- data/ext/page.cpp +107 -0
- data/ext/page.h +51 -0
- data/ext/pipe.cpp +347 -0
- data/ext/project.h +155 -0
- data/ext/rubymain.cpp +1200 -0
- data/ext/ssl.cpp +460 -0
- data/ext/ssl.h +94 -0
- data/java/.classpath +8 -0
- data/java/.project +17 -0
- data/java/src/com/rubyeventmachine/EmReactor.java +571 -0
- data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
- data/java/src/com/rubyeventmachine/EventableChannel.java +69 -0
- data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +189 -0
- data/java/src/com/rubyeventmachine/EventableSocketChannel.java +364 -0
- data/lib/em/buftok.rb +138 -0
- data/lib/em/callback.rb +26 -0
- data/lib/em/channel.rb +57 -0
- data/lib/em/connection.rb +569 -0
- data/lib/em/deferrable.rb +206 -0
- data/lib/em/file_watch.rb +54 -0
- data/lib/em/future.rb +61 -0
- data/lib/em/iterator.rb +270 -0
- data/lib/em/messages.rb +66 -0
- data/lib/em/process_watch.rb +44 -0
- data/lib/em/processes.rb +119 -0
- data/lib/em/protocols.rb +36 -0
- data/lib/em/protocols/header_and_content.rb +138 -0
- data/lib/em/protocols/httpclient.rb +268 -0
- data/lib/em/protocols/httpclient2.rb +590 -0
- data/lib/em/protocols/line_and_text.rb +125 -0
- data/lib/em/protocols/line_protocol.rb +28 -0
- data/lib/em/protocols/linetext2.rb +161 -0
- data/lib/em/protocols/memcache.rb +323 -0
- data/lib/em/protocols/object_protocol.rb +45 -0
- data/lib/em/protocols/postgres3.rb +247 -0
- data/lib/em/protocols/saslauth.rb +175 -0
- data/lib/em/protocols/smtpclient.rb +357 -0
- data/lib/em/protocols/smtpserver.rb +640 -0
- data/lib/em/protocols/socks4.rb +66 -0
- data/lib/em/protocols/stomp.rb +200 -0
- data/lib/em/protocols/tcptest.rb +53 -0
- data/lib/em/pure_ruby.rb +1013 -0
- data/lib/em/queue.rb +62 -0
- data/lib/em/spawnable.rb +85 -0
- data/lib/em/streamer.rb +130 -0
- data/lib/em/tick_loop.rb +85 -0
- data/lib/em/timers.rb +57 -0
- data/lib/em/version.rb +3 -0
- data/lib/eventmachine.rb +1548 -0
- data/lib/jeventmachine.rb +258 -0
- data/lib/rubyeventmachine.rb +2 -0
- data/setup.rb +1585 -0
- data/tasks/cpp.rake_example +77 -0
- data/tasks/doc.rake +30 -0
- data/tasks/package.rake +85 -0
- data/tasks/test.rake +6 -0
- data/tests/client.crt +31 -0
- data/tests/client.key +51 -0
- data/tests/test_attach.rb +136 -0
- data/tests/test_basic.rb +249 -0
- data/tests/test_channel.rb +64 -0
- data/tests/test_connection_count.rb +35 -0
- data/tests/test_defer.rb +49 -0
- data/tests/test_deferrable.rb +35 -0
- data/tests/test_epoll.rb +160 -0
- data/tests/test_error_handler.rb +35 -0
- data/tests/test_errors.rb +82 -0
- data/tests/test_exc.rb +55 -0
- data/tests/test_file_watch.rb +49 -0
- data/tests/test_futures.rb +198 -0
- data/tests/test_get_sock_opt.rb +30 -0
- data/tests/test_handler_check.rb +37 -0
- data/tests/test_hc.rb +190 -0
- data/tests/test_httpclient.rb +227 -0
- data/tests/test_httpclient2.rb +154 -0
- data/tests/test_inactivity_timeout.rb +50 -0
- data/tests/test_kb.rb +60 -0
- data/tests/test_ltp.rb +190 -0
- data/tests/test_ltp2.rb +317 -0
- data/tests/test_next_tick.rb +133 -0
- data/tests/test_object_protocol.rb +37 -0
- data/tests/test_pause.rb +70 -0
- data/tests/test_pending_connect_timeout.rb +48 -0
- data/tests/test_process_watch.rb +50 -0
- data/tests/test_processes.rb +128 -0
- data/tests/test_proxy_connection.rb +144 -0
- data/tests/test_pure.rb +134 -0
- data/tests/test_queue.rb +44 -0
- data/tests/test_running.rb +42 -0
- data/tests/test_sasl.rb +72 -0
- data/tests/test_send_file.rb +251 -0
- data/tests/test_servers.rb +76 -0
- data/tests/test_smtpclient.rb +83 -0
- data/tests/test_smtpserver.rb +85 -0
- data/tests/test_spawn.rb +322 -0
- data/tests/test_ssl_args.rb +79 -0
- data/tests/test_ssl_methods.rb +50 -0
- data/tests/test_ssl_verify.rb +82 -0
- data/tests/test_tick_loop.rb +59 -0
- data/tests/test_timers.rb +160 -0
- data/tests/test_ud.rb +36 -0
- data/tests/testem.rb +31 -0
- metadata +240 -0
@@ -0,0 +1,133 @@
|
|
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'
|
31
|
+
|
32
|
+
class TestNextTick < Test::Unit::TestCase
|
33
|
+
|
34
|
+
def test_tick_arg
|
35
|
+
pr = proc {EM.stop}
|
36
|
+
EM.run {
|
37
|
+
EM.next_tick pr
|
38
|
+
}
|
39
|
+
assert true
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_tick_block
|
43
|
+
EM.run {
|
44
|
+
EM.next_tick {EM.stop}
|
45
|
+
}
|
46
|
+
assert true
|
47
|
+
end
|
48
|
+
|
49
|
+
# This illustrates the solution to a long-standing problem.
|
50
|
+
# It's now possible to correctly nest calls to EM#run.
|
51
|
+
# See the source code commentary for EM#run for more info.
|
52
|
+
#
|
53
|
+
def test_run_run
|
54
|
+
EM.run {
|
55
|
+
EM.run {
|
56
|
+
EM.next_tick {EM.stop}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_pre_run_queue
|
62
|
+
x = false
|
63
|
+
EM.next_tick { EM.stop; x = true }
|
64
|
+
EM.run { EM.add_timer(0.01) { EM.stop } }
|
65
|
+
assert x
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_cleanup_after_stop
|
69
|
+
x = true
|
70
|
+
EM.run{
|
71
|
+
EM.next_tick{
|
72
|
+
EM.stop
|
73
|
+
EM.next_tick{ x=false }
|
74
|
+
}
|
75
|
+
}
|
76
|
+
EM.run{
|
77
|
+
EM.next_tick{ EM.stop }
|
78
|
+
}
|
79
|
+
assert x
|
80
|
+
end
|
81
|
+
|
82
|
+
# We now support an additional parameter for EM#run.
|
83
|
+
# You can pass two procs to EM#run now. The first is executed as the normal
|
84
|
+
# run block. The second (if given) is scheduled for execution after the
|
85
|
+
# reactor loop completes.
|
86
|
+
# The reason for supporting this is subtle. There has always been an expectation
|
87
|
+
# that EM#run doesn't return until after the reactor loop ends. But now it's
|
88
|
+
# possible to nest calls to EM#run, which means that a nested call WILL
|
89
|
+
# RETURN. In order to write code that will run correctly either way, it's
|
90
|
+
# recommended to put any code which must execute after the reactor completes
|
91
|
+
# in the second parameter.
|
92
|
+
#
|
93
|
+
def test_run_run_2
|
94
|
+
a = proc {EM.stop}
|
95
|
+
b = proc {assert true}
|
96
|
+
EM.run a, b
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
# This illustrates that EM#run returns when it's called nested.
|
101
|
+
# This isn't a feature, rather it's something to be wary of when writing code
|
102
|
+
# that must run correctly even if EM#run is called while a reactor is already
|
103
|
+
# running.
|
104
|
+
def test_run_run_3
|
105
|
+
a = []
|
106
|
+
EM.run {
|
107
|
+
EM.run proc {EM.stop}, proc {a << 2}
|
108
|
+
a << 1
|
109
|
+
}
|
110
|
+
assert_equal( [1,2], a )
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
def test_schedule_on_reactor_thread
|
115
|
+
x = false
|
116
|
+
EM.run do
|
117
|
+
EM.schedule { x = true }
|
118
|
+
EM.stop
|
119
|
+
end
|
120
|
+
assert x
|
121
|
+
end
|
122
|
+
|
123
|
+
def test_schedule_from_thread
|
124
|
+
x = false
|
125
|
+
EM.run do
|
126
|
+
Thread.new { EM.schedule { x = true } }.join
|
127
|
+
assert !x
|
128
|
+
EM.next_tick { EM.stop }
|
129
|
+
end
|
130
|
+
assert x
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
$:.unshift "../lib"
|
2
|
+
require 'eventmachine'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class TestObjectProtocol < Test::Unit::TestCase
|
6
|
+
Host = "127.0.0.1"
|
7
|
+
Port = 9550
|
8
|
+
|
9
|
+
module Server
|
10
|
+
include EM::P::ObjectProtocol
|
11
|
+
def post_init
|
12
|
+
send_object :hello=>'world'
|
13
|
+
end
|
14
|
+
def receive_object obj
|
15
|
+
$server = obj
|
16
|
+
EM.stop
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module Client
|
21
|
+
include EM::P::ObjectProtocol
|
22
|
+
def receive_object obj
|
23
|
+
$client = obj
|
24
|
+
send_object 'you_said'=>obj
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_send_receive
|
29
|
+
EM.run{
|
30
|
+
EM.start_server Host, Port, Server
|
31
|
+
EM.connect Host, Port, Client
|
32
|
+
}
|
33
|
+
|
34
|
+
assert($client == {:hello=>'world'})
|
35
|
+
assert($server == {'you_said'=>{:hello=>'world'}})
|
36
|
+
end
|
37
|
+
end
|
data/tests/test_pause.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
$:.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
|
2
|
+
require 'eventmachine'
|
3
|
+
require 'socket'
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
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
|
17
|
+
|
18
|
+
#-------------------------------------
|
19
|
+
|
20
|
+
def test_pause_resume
|
21
|
+
test = self
|
22
|
+
server = nil
|
23
|
+
|
24
|
+
s_rx = c_rx = 0
|
25
|
+
|
26
|
+
EM.run do
|
27
|
+
EM.start_server TestHost, TestPort, Module.new {
|
28
|
+
define_method :post_init do
|
29
|
+
server = self
|
30
|
+
end
|
31
|
+
|
32
|
+
define_method :receive_data do |data|
|
33
|
+
s_rx += 1
|
34
|
+
|
35
|
+
EM.add_periodic_timer(0.01) { send_data 'hi' }
|
36
|
+
send_data 'hi'
|
37
|
+
|
38
|
+
# pause server, now no outgoing data will actually
|
39
|
+
# be sent and no more incoming data will be received
|
40
|
+
pause
|
41
|
+
end
|
42
|
+
}
|
43
|
+
|
44
|
+
c = EM.connect TestHost, TestPort, Module.new {
|
45
|
+
define_method :receive_data do |data|
|
46
|
+
c_rx += 1
|
47
|
+
end
|
48
|
+
}
|
49
|
+
EM.add_periodic_timer(0.01) { c.send_data 'hi' }
|
50
|
+
|
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?
|
55
|
+
|
56
|
+
# resume server, queued outgoing and incoming data will be flushed
|
57
|
+
server.resume
|
58
|
+
|
59
|
+
test.assert ! server.paused?
|
60
|
+
|
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
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
$:.unshift "../lib"
|
2
|
+
require 'eventmachine'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class TestPendingConnectTimeout < Test::Unit::TestCase
|
6
|
+
|
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
|
29
|
+
|
30
|
+
module TimeoutHandler
|
31
|
+
def unbind
|
32
|
+
EM.stop
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
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
|
+
}
|
44
|
+
|
45
|
+
assert_in_delta(0.2, (Time.now - $start), 0.1)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
$:.unshift "../lib"
|
2
|
+
require 'eventmachine'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
if EM.kqueue?
|
6
|
+
class TestProcessWatch < Test::Unit::TestCase
|
7
|
+
module ParentProcessWatcher
|
8
|
+
def process_forked
|
9
|
+
$forked = true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module ChildProcessWatcher
|
14
|
+
def process_exited
|
15
|
+
$exited = true
|
16
|
+
end
|
17
|
+
def unbind
|
18
|
+
$unbind = true
|
19
|
+
EM.stop
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def setup
|
24
|
+
EM.kqueue = true
|
25
|
+
end
|
26
|
+
|
27
|
+
def teardown
|
28
|
+
EM.kqueue = false
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_events
|
32
|
+
EM.run{
|
33
|
+
# watch ourselves for a fork notification
|
34
|
+
EM.watch_process(Process.pid, ParentProcessWatcher)
|
35
|
+
$fork_pid = fork{ sleep }
|
36
|
+
child = EM.watch_process($fork_pid, ChildProcessWatcher)
|
37
|
+
$pid = child.pid
|
38
|
+
|
39
|
+
EM.add_timer(0.2){
|
40
|
+
Process.kill('TERM', $fork_pid)
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
assert_equal($pid, $fork_pid)
|
45
|
+
assert($forked)
|
46
|
+
assert($exited)
|
47
|
+
assert($unbind)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,128 @@
|
|
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'
|
30
|
+
|
31
|
+
class TestProcesses < Test::Unit::TestCase
|
32
|
+
|
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
|
50
|
+
}
|
51
|
+
}
|
52
|
+
assert( ls.length > 0)
|
53
|
+
end
|
54
|
+
|
55
|
+
def setup
|
56
|
+
$out = nil
|
57
|
+
$status = nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_em_system
|
61
|
+
EM.run{
|
62
|
+
EM.system('ls'){ |out,status| $out, $status = out, status; EM.stop }
|
63
|
+
}
|
64
|
+
|
65
|
+
assert( $out.length > 0 )
|
66
|
+
assert_equal($status.exitstatus, 0)
|
67
|
+
assert_equal($status.class, Process::Status)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_em_system_pid
|
71
|
+
$pids = []
|
72
|
+
|
73
|
+
EM.run{
|
74
|
+
$pids << EM.system('echo hi', proc{ |out,status|$pids << status.pid; EM.stop })
|
75
|
+
}
|
76
|
+
|
77
|
+
assert_equal $pids[0], $pids[1]
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_em_system_with_proc
|
81
|
+
EM.run{
|
82
|
+
EM.system('ls', proc{ |out,status| $out, $status = out, status; EM.stop })
|
83
|
+
}
|
84
|
+
|
85
|
+
assert( $out.length > 0 )
|
86
|
+
assert_equal($status.exitstatus, 0)
|
87
|
+
assert_equal($status.class, Process::Status)
|
88
|
+
end
|
89
|
+
|
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
|
104
|
+
|
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
|
117
|
+
|
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
|
+
}
|
125
|
+
|
126
|
+
assert_equal("hello\n", $out)
|
127
|
+
end
|
128
|
+
end
|