From 224b7604c1540d2f2d1a9f805f0fbc9bf480d627 Mon Sep 17 00:00:00 2001 From: Eliot Sykes Date: Thu, 15 Jan 2026 11:21:17 +0000 Subject: [PATCH] Prevent skipped examples from hanging rspec-queue --- ruby/lib/rspec/queue.rb | 3 +- ruby/test/fixtures/pending/spec/dummy_spec.rb | 10 ++++ .../test/fixtures/pending/spec/spec_helper.rb | 4 ++ ruby/test/integration/rspec_redis_test.rb | 49 +++++++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 ruby/test/fixtures/pending/spec/dummy_spec.rb create mode 100644 ruby/test/fixtures/pending/spec/spec_helper.rb diff --git a/ruby/lib/rspec/queue.rb b/ruby/lib/rspec/queue.rb index c92d6703..aebb89c8 100644 --- a/ruby/lib/rspec/queue.rb +++ b/ruby/lib/rspec/queue.rb @@ -226,6 +226,7 @@ def finish(reporter, acknowledge: true) dup.mark_as_requeued!(reporter) return true else + reporter.acknowledge if skipped? super(reporter) end else @@ -422,7 +423,7 @@ def cancel_run! end def acknowledge - @queue.acknowledge(@example) + @queue.acknowledge(@example.id) end end diff --git a/ruby/test/fixtures/pending/spec/dummy_spec.rb b/ruby/test/fixtures/pending/spec/dummy_spec.rb new file mode 100644 index 00000000..b6b65e4b --- /dev/null +++ b/ruby/test/fixtures/pending/spec/dummy_spec.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true +RSpec.describe Object do + it "works" do + expect(1 + 1).to be == 2 + end + + xit "pending 'xit' example should be ignored" do + expect(true).to eq false + end +end diff --git a/ruby/test/fixtures/pending/spec/spec_helper.rb b/ruby/test/fixtures/pending/spec/spec_helper.rb new file mode 100644 index 00000000..205ba26b --- /dev/null +++ b/ruby/test/fixtures/pending/spec/spec_helper.rb @@ -0,0 +1,4 @@ +# frozen_string_literal: true +RSpec.configure do |config| + config.backtrace_inclusion_patterns << %r{/test/fixtures/} +end diff --git a/ruby/test/integration/rspec_redis_test.rb b/ruby/test/integration/rspec_redis_test.rb index 77a2ab5a..c4fec3b5 100644 --- a/ruby/test/integration/rspec_redis_test.rb +++ b/ruby/test/integration/rspec_redis_test.rb @@ -152,6 +152,55 @@ def test_redis_runner_retry assert_equal 0, $?.exitstatus end + def test_redis_runner_pending + @order_path = File.expand_path('../../fixtures/pending/log/test_order.log', __FILE__) + out, err = capture_subprocess_io do + system( + { 'BUILDKITE' => '1', 'BUILDKITE_COMMIT' => 'aaaaaaaaaaaaa' }, + @exe, + '--queue', @redis_url, + '--seed', '123', + '--build', '1', + '--worker', '1', + '--timeout', '1', + chdir: 'test/fixtures/pending', + ) + assert_equal 0, $?.exitstatus + end + + assert_empty err + expected_output = strip_heredoc <<-EOS + Worker elected as leader, pushing 2 tests to the queue. + + Finished pushing 2 tests to the queue in X.XXs. + + Randomized with seed 123 + .* + + Pending: (Failures listed here are expected and do not affect your suite's status) + + 1) Object pending 'xit' example should be ignored + # Temporarily skipped with xit + # ./spec/dummy_spec.rb:7 + + Finished in X.XXXXX seconds (files took X.XXXXX seconds to load) + 2 examples, 0 failures, 1 pending + + Randomized with seed 123 + + EOS + + assert_equal expected_output, normalize(out) + + + expected_test_order = [ + "./spec/dummy_spec.rb[1:1]\n", + "./spec/dummy_spec.rb[1:2]\n", + ] + + assert_equal expected_test_order, File.read(@order_path).lines + end + def test_retry_report # Run first worker, failing all tests out, err = capture_subprocess_io do