Sha256: 24dfd0e9ab6740a3d08b5c98690e28800e8333f0645bcfee721c31eca8d106cd

Contents?: true

Size: 1.65 KB

Versions: 19

Compression:

Stored size: 1.65 KB

Contents

require File.expand_path('../spec_helper', __FILE__)
require "pid_behavior"

if ChildProcess.unix? && !ChildProcess.jruby? && !ChildProcess.posix_spawn?

  describe ChildProcess::Unix::Process do
    it_behaves_like "a platform that provides the child's pid"

    it "handles ECHILD race condition where process dies between timeout and KILL" do
      process = sleeping_ruby

      process.stub!(:fork).and_return('fakepid')
      process.stub!(:send_term)
      process.stub!(:poll_for_exit).and_raise(ChildProcess::TimeoutError)
      process.stub!(:send_kill).and_raise(Errno::ECHILD.new)

      process.start
      lambda { process.stop }.should_not raise_error

      process.stub(:alive?).and_return(false)
    end

    it "handles ESRCH race condition where process dies between timeout and KILL" do
      process = sleeping_ruby

      process.stub!(:fork).and_return('fakepid')
      process.stub!(:send_term)
      process.stub!(:poll_for_exit).and_raise(ChildProcess::TimeoutError)
      process.stub!(:send_kill).and_raise(Errno::ESRCH.new)

      process.start
      lambda { process.stop }.should_not raise_error

      process.stub(:alive?).and_return(false)
    end
  end

  describe ChildProcess::Unix::IO do
    let(:io) { ChildProcess::Unix::IO.new }

    it "raises an ArgumentError if given IO does not respond to :to_io" do
      lambda { io.stdout = nil }.should raise_error(ArgumentError, /to respond to :to_io/)
    end

    it "raises a TypeError if #to_io does not return an IO" do
      fake_io = Object.new
      def fake_io.to_io() StringIO.new end

      lambda { io.stdout = fake_io }.should raise_error(TypeError, /expected IO, got/)
    end
  end

end

Version data entries

19 entries across 19 versions & 7 rubygems

Version Path
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.9/spec/unix_spec.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.9/spec/unix_spec.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.9/spec/unix_spec.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.9/spec/unix_spec.rb
vagrant-shell-0.2.6 vendor/bundle/gems/childprocess-0.3.9/spec/unix_spec.rb
vagrant-shell-0.2.5 vendor/bundle/gems/childprocess-0.3.9/spec/unix_spec.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/childprocess-0.3.8/spec/unix_spec.rb
vagrant-actionio-0.0.9 vendor/bundle/gems/childprocess-0.3.9/spec/unix_spec.rb
childprocess-0.3.9 spec/unix_spec.rb
librarian-puppet-0.9.8 vendor/gems/ruby/1.9.1/gems/childprocess-0.3.8/spec/unix_spec.rb
childprocess-0.3.8 spec/unix_spec.rb
childprocess-0.3.7 spec/unix_spec.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.6/spec/unix_spec.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/childprocess-0.3.6/spec/unix_spec.rb
childprocess-0.3.6 spec/unix_spec.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/childprocess-0.3.5/spec/unix_spec.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/childprocess-0.3.5/spec/unix_spec.rb
childprocess-0.3.5 spec/unix_spec.rb
childprocess-0.3.4 spec/unix_spec.rb