diff --git a/lib/parallel_tests.rb b/lib/parallel_tests.rb index 356ba7ef..48e9c94e 100644 --- a/lib/parallel_tests.rb +++ b/lib/parallel_tests.rb @@ -44,6 +44,8 @@ def pid_file_path def stop_all_processes pids.all.each { |pid| Process.kill(:INT, pid) } + rescue Errno::ESRCH + # Process already terminated, do nothing end # copied from http://github.com/carlhuda/bundler Bundler::SharedHelpers#find_gemfile diff --git a/spec/parallel_tests_spec.rb b/spec/parallel_tests_spec.rb index fe87e435..bed4b9b6 100644 --- a/spec/parallel_tests_spec.rb +++ b/spec/parallel_tests_spec.rb @@ -194,6 +194,13 @@ def with_running_processes(count, wait = 0.2) expect(ParallelTests.pids.count).to eq(0) end end + + it "doesn't fail if the pid has already been killed", unless: Gem.win_platform? do + ParallelTests.with_pid_file do + ParallelTests.pids.add(1234) + expect { ParallelTests.stop_all_processes }.not_to raise_error + end + end end it "has a version" do