Sha256: dc587271a540075a97ea90c1fa96b8105f2b4e3a6e959a35d1989b580152555f

Contents?: true

Size: 924 Bytes

Versions: 78

Compression:

Stored size: 924 Bytes

Contents

require 'em_test_helper'

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

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

    def setup
      EM.kqueue = true
    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

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

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

Version data entries

78 entries across 78 versions & 6 rubygems

Version Path
sensu-em-2.4.1-java tests/test_process_watch.rb
sensu-em-2.4.1 tests/test_process_watch.rb
eventmachine-1.0.4-java tests/test_process_watch.rb
eventmachine-1.0.4 tests/test_process_watch.rb
sensu-em-2.4.0-x86-mingw32 tests/test_process_watch.rb
eventmachine-le-1.1.7 tests/test_process_watch.rb
sonixlabs-eventmachine-java-1.0.3.2-java tests/test_process_watch.rb
sonixlabs-eventmachine-java-1.0.3.1-java tests/test_process_watch.rb
sonixlabs-eventmachine-java-1.0.3.1 tests/test_process_watch.rb
sensu-em-2.4.0-java tests/test_process_watch.rb
sensu-em-2.4.0 tests/test_process_watch.rb
sensu-em-2.3.0-java tests/test_process_watch.rb
sensu-em-2.3.0 tests/test_process_watch.rb
sensu-em-2.2.0-java tests/test_process_watch.rb
sensu-em-2.2.0 tests/test_process_watch.rb
sensu-em-2.1.0-java tests/test_process_watch.rb
sensu-em-2.1.0 tests/test_process_watch.rb
sensu-em-2.0.0-java tests/test_process_watch.rb
sensu-em-2.0.0 tests/test_process_watch.rb
sonixlabs-eventmachine-java-1.0.0.rc.7-java tests/test_process_watch.rb