Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure no error is raised when a process is already terminated #939

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading