Skip to content

Commit a0373af

Browse files
authored
Make sure no error is raised when a process is already terminated (grosser#939)
1 parent 24f150c commit a0373af

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/parallel_tests.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ def pid_file_path
4444

4545
def stop_all_processes
4646
pids.all.each { |pid| Process.kill(:INT, pid) }
47+
rescue Errno::ESRCH
48+
# Process already terminated, do nothing
4749
end
4850

4951
# copied from http://github.com/carlhuda/bundler Bundler::SharedHelpers#find_gemfile

spec/parallel_tests_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ def with_running_processes(count, wait = 0.2)
194194
expect(ParallelTests.pids.count).to eq(0)
195195
end
196196
end
197+
198+
it "doesn't fail if the pid has already been killed", unless: Gem.win_platform? do
199+
ParallelTests.with_pid_file do
200+
ParallelTests.pids.add(1234)
201+
expect { ParallelTests.stop_all_processes }.not_to raise_error
202+
end
203+
end
197204
end
198205

199206
it "has a version" do

0 commit comments

Comments
 (0)