Skip to content

Commit

Permalink
Skip over the TestProcessWatch class if kqueue is not supported.
Browse files Browse the repository at this point in the history
This test failed on Linux as kqueue was not supported, but the test wasn't
skipped before. Now the testsuite passes green on both 1.8 and 1.9.

Signed-off-by: Aman Gupta <aman@tmm1.net>
  • Loading branch information
Flameeyes authored and tmm1 committed May 29, 2010
1 parent 006aa89 commit 238eeea
Showing 1 changed file with 36 additions and 34 deletions.
70 changes: 36 additions & 34 deletions tests/test_process_watch.rb
Expand Up @@ -2,47 +2,49 @@
require 'eventmachine'
require 'test/unit'

class TestProcessWatch < Test::Unit::TestCase
module ParentProcessWatcher
def process_forked
$forked = true
if EM.kqueue?
class TestProcessWatch < Test::Unit::TestCase
module ParentProcessWatcher
def process_forked
$forked = true
end
end
end

module ChildProcessWatcher
def process_exited
$exited = true
end
def unbind
$unbind = true
EM.stop
module ChildProcessWatcher
def process_exited
$exited = true
end
def unbind
$unbind = true
EM.stop
end
end
end

def setup
EM.kqueue = true if EM.kqueue?
end
def setup
EM.kqueue = true
end

def teardown
EM.kqueue = false if EM.kqueue?
end
def teardown
EM.kqueue = false
end

def test_events
EM.run{
# watch ourselves for a fork notification
EM.watch_process(Process.pid, ParentProcessWatcher)
$fork_pid = fork{ sleep }
child = EM.watch_process($fork_pid, ChildProcessWatcher)
$pid = child.pid
def test_events
EM.run{
# watch ourselves for a fork notification
EM.watch_process(Process.pid, ParentProcessWatcher)
$fork_pid = fork{ sleep }
child = EM.watch_process($fork_pid, ChildProcessWatcher)
$pid = child.pid

EM.add_timer(0.2){
Process.kill('TERM', $fork_pid)
EM.add_timer(0.2){
Process.kill('TERM', $fork_pid)
}
}
}

assert_equal($pid, $fork_pid)
assert($forked)
assert($exited)
assert($unbind)
assert_equal($pid, $fork_pid)
assert($forked)
assert($exited)
assert($unbind)
end
end
end
end

0 comments on commit 238eeea

Please sign in to comment.