spec/spec.wait_pid.rb in wait_pid-0.0.2 vs spec/spec.wait_pid.rb in wait_pid-0.1.0

- old
+ new

@@ -5,37 +5,46 @@ def spawn command # should return a pid if RUBY_VERSION < '1.9' if OS.linux? - fork { system(command) } + a = fork { system(command) } else - raise 'todo' + raise 'todo' # too lazy end else - Process.spawn command + a = Process.spawn command end + Thread.new { Process.wait a } # gotta wait for it, or, as child, it never "really" ends in terms of sig 0 + a end describe "wait pid" do it "should warn if a pid doesn't exist" do - out = WaitPid.wait_pid 1234, true + out = WaitPid.wait_nonchild_pid 1234, true out.should be_a(String) end it "should work without a second argument" do - WaitPid.wait_pid 1234 + WaitPid.wait_nonchild_pid 1234 end - + + it "should wait on a pid" do a = spawn 'ruby -e "sleep 1"' - Thread.new { Process.wait a } # gotta wait for it, or, as child, it never "really" ends in terms of sig 0 start = Time.now - WaitPid.wait_pid(a) + WaitPid.wait_nonchild_pid(a) assert(Time.now - start > 0.5) end - it "should be able to wait on more than one pid" + it "should be able to wait on more than one pid" do + a = spawn 'ruby -e "sleep 0.5"' + b = spawn 'ruby -e "sleep 1"' + start = Time.now + WaitPid.wait_nonchild_pids a, b + assert(Time.now - start > 0.75) + end + it "should be able to optionally output when each of those several dies" end