Sha256: aff44d4518a69b5357a24115b81af920f7bb5f9e9219cfb0718b64a60617bf3c

Contents?: true

Size: 966 Bytes

Versions: 60

Compression:

Stored size: 966 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
      omit_if(rbx?)
      omit_if(jruby?)
      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

60 entries across 57 versions & 5 rubygems

Version Path
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/3.1.0/gems/eventmachine-1.2.7/tests/test_process_watch.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/3.0.0/gems/eventmachine-1.2.7/tests/test_process_watch.rb
devcycle-ruby-server-sdk-1.1.0 examples/sinatra/vendor/bundle/ruby/2.6.0/gems/eventmachine-1.2.7/tests/test_process_watch.rb
sensu-em-2.7.0-java tests/test_process_watch.rb
eventmachine-1.2.7-java tests/test_process_watch.rb
eventmachine-1.2.7-x64-mingw32 tests/test_process_watch.rb
eventmachine-1.2.7-x86-mingw32 tests/test_process_watch.rb
eventmachine-1.2.7 tests/test_process_watch.rb
eventmachine-1.2.6-x64-mingw32 tests/test_process_watch.rb
eventmachine-1.2.6-x86-mingw32 tests/test_process_watch.rb
eventmachine-1.2.6-java tests/test_process_watch.rb
eventmachine-1.2.6 tests/test_process_watch.rb
eventmachine-1.2.5-x86-mingw32 tests/test_process_watch.rb
eventmachine-1.2.5-x64-mingw32 tests/test_process_watch.rb
eventmachine-1.2.5-java tests/test_process_watch.rb
eventmachine-1.2.5 tests/test_process_watch.rb
eventmachine-1.2.3-x64-mingw32 tests/test_process_watch.rb
eventmachine-1.2.3-x86-mingw32 tests/test_process_watch.rb
eventmachine-1.2.3-java tests/test_process_watch.rb
eventmachine-1.2.3 tests/test_process_watch.rb