spec/pool_spec.rb in spool-1.0.4 vs spec/pool_spec.rb in spool-1.0.5

- old
+ new

@@ -19,10 +19,11 @@ t = Thread.new { pool.start } t.abort_on_exception = true while pool.all_processes.count < pool.configuration.processes sleep 0.01 end + sleep 0.1 end end def assert_with_timeout(timeout, &block) Timeout.timeout(timeout) do @@ -117,25 +118,27 @@ end until (original_pids & new_pids).empty? pool.all_processes.each { |p| p.must_be :alive?} end - it 'Stop with timeout' do + it 'Stop waits for children to die gracefully' do pool = start_pool do processes 1 - command 'ruby -e "Signal.trap(:QUIT) { puts :quit; sleep 5; exit 0 }; loop { sleep 1 }"' + command 'ruby -e "Signal.trap(:QUIT) { sleep 2; exit 0 }; loop { sleep 1 }"' stop_signal :QUIT end + sleep 1 + process = pool.all_processes[0] - + Benchmark.realtime do - pool.stop 0.1 + pool.stop while pool.running? sleep SLEEP_TIME end - end.must_be :<, 1 - + end.must_be :>, 2 + pool.must_be :stopped? pool.all_processes.must_be_empty process.wont_be :alive? end \ No newline at end of file