From ed95a612c4f34e86bcdc49cfc63704fbd3e4711d Mon Sep 17 00:00:00 2001 From: Benoit Tigeot Date: Sat, 14 Dec 2019 15:22:36 +0100 Subject: [PATCH] [core] Avoid bisect command to get stuck (rspec/rspec-core#2669) Avoid bisect command to get stuck --- This commit was imported from https://github.com/rspec/rspec-core/commit/1c31fc4a2a265082b3cec8f6878f258337c0fcd0. --- rspec-core/lib/rspec/core/bisect/fork_runner.rb | 5 +++-- rspec-core/spec/integration/bisect_spec.rb | 10 ++++++++++ .../rspec/core/resources/blocking_pipe_bisect_spec.rb_ | 8 ++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 rspec-core/spec/rspec/core/resources/blocking_pipe_bisect_spec.rb_ diff --git a/rspec-core/lib/rspec/core/bisect/fork_runner.rb b/rspec-core/lib/rspec/core/bisect/fork_runner.rb index 38647e7af..ced21c96e 100644 --- a/rspec-core/lib/rspec/core/bisect/fork_runner.rb +++ b/rspec-core/lib/rspec/core/bisect/fork_runner.rb @@ -91,8 +91,9 @@ def initialize(runner, channel) end def dispatch_specs(run_descriptor) - pid = fork { run_specs(run_descriptor) } - Process.waitpid(pid) + fork { run_specs(run_descriptor) } + # We don't use Process.waitpid here as it was causing bisects to + # block due to the file descriptor limit on OSX / Linux. end private diff --git a/rspec-core/spec/integration/bisect_spec.rb b/rspec-core/spec/integration/bisect_spec.rb index c39eff8fa..1d3a86439 100644 --- a/rspec-core/spec/integration/bisect_spec.rb +++ b/rspec-core/spec/integration/bisect_spec.rb @@ -32,5 +32,15 @@ def bisect(cli_args, expected_status=nil) expect(output).to include("Bisect failed!", "The example ordering is inconsistent") end end + + context "when the bisect commasaturingnd is long" do + # On OSX and Linux a file descriptor limit meant that the bisect process got stuck at a certain limit. + # This test demonstrates that we can run large bisects above this limit (found to be at time of commit). + # See: https://github.com/rspec/rspec-core/pull/2669 + it 'does not hit pipe size limit and does not get stuck' do + output = bisect(%W[spec/rspec/core/resources/blocking_pipe_bisect_spec.rb_], 1) + expect(output).to include("No failures found.") + end + end end end diff --git a/rspec-core/spec/rspec/core/resources/blocking_pipe_bisect_spec.rb_ b/rspec-core/spec/rspec/core/resources/blocking_pipe_bisect_spec.rb_ new file mode 100644 index 000000000..7d7a0a1e6 --- /dev/null +++ b/rspec-core/spec/rspec/core/resources/blocking_pipe_bisect_spec.rb_ @@ -0,0 +1,8 @@ +# Deliberately named *.rb_ to avoid being loaded except when specified + +RSpec.describe "1000 tests" do + puts "Try to saturate the pipe in Bisect command" + (0..1000).each do |t| + it { expect(t).to eq t } + end +end