Skip to content

Commit

Permalink
Make sure no error is raised when a process is already terminated
Browse files Browse the repository at this point in the history
  • Loading branch information
louim committed Mar 5, 2024
1 parent 24f150c commit c5eb414
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/parallel_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions spec/parallel_tests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c5eb414

Please sign in to comment.