Sha256: b4225fca044212219062b3762f041acd39c412ad1c5e8fdc5a3dced3af60ce58

Contents?: true

Size: 1.04 KB

Versions: 7

Compression:

Stored size: 1.04 KB

Contents

require 'pione/test-helper'

def test_available?
  begin
    pid = Process.spawn("sleep", "100")
    Process.kill(:TERM, pid)
    return true
  rescue
    return false
  end
end

describe "Pione::Util::ProcessInfo" do
  if test_available?
    before do
      @pid = Process.spawn("sleep", "100")
      @thread = Process.detach(@pid)
      @info = Util::ProcessInfo.new(@pid, @thread)
    end

    after do
      @info.kill if @info.alive?
    end

    it "should get pid" do
      @info.pid.should == @pid
    end

    it "should get process watching thread" do
      @info.thread.should == @thread
    end

    it "should be alive" do
      @info.should.alive
    end

    it "should kill the process" do
      @info.kill
      @info.should.not.alive
    end

    it "should be stopped" do
      @info.kill
      @info.should.stop
    end

    it "should wait" do
      should.raise(Timeout::Error) do
        timeout(1) {@info.wait}
      end
    end
  else
    puts "*** test of Pione::Util::ProcessInfo is not available in this environment ***"
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pione-0.5.0.alpha.1 test/util/spec_process-info.rb
pione-0.4.2 test/util/spec_process-info.rb
pione-0.4.1 test/util/spec_process-info.rb
pione-0.4.0 test/util/spec_process-info.rb
pione-0.3.2 test/util/spec_process-info.rb
pione-0.3.1 test/util/spec_process-info.rb
pione-0.3.0 test/util/spec_process-info.rb