fix(rspec): quarantine fixed-pending examples instead of hard-failing#1141
Merged
Conversation
A `pending` example whose body now passes is turned by RSpec into a real failure (PendingExampleFixedError) that reds the build. Example#set_exception short-circuited on metadata[:pending] before reaching handle_quarantine_check, so such an example never consulted the quarantine list: a fixed-pending test the user had quarantined still failed the build and uploaded as a plain, un-quarantined failure (is_quarantined derives from metadata[:quarantined_exception], which only handle_quarantine_check sets). - set_exception: let a PendingExampleFixedError fall through to the quarantine check (ordinary still-failing pending examples stay green). - status_and_exception: when the swallowed fixed-pending leaves RSpec at :pending, use execution_result.pending_fixed? to still report it as a failure carrying the fixed error, so it serializes as failure + quarantined. Coverage (ruby gem upload action), mirroring variant_quarantine_spec.rb: - spec/pending_spec.rb: a fixed-pending example. - with-variant step now runs variant_quarantine_spec.rb + pending_spec.rb and asserts the run passes (both quarantined under smoke-test-variant). - new no-variant step runs pending_spec.rb alone and asserts a non-zero exit, isolating the fixed-pending failure when it is not quarantined. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RHvMvkpGYtQYZ3FQ4j2w65
|
😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1141 +/- ##
==========================================
+ Coverage 82.65% 82.77% +0.12%
==========================================
Files 70 70
Lines 15588 15588
==========================================
+ Hits 12884 12903 +19
+ Misses 2704 2685 -19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
acatxnamedvirtue
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Was seeing this pending fixed not being quarantined properly: https://github.com/trunk-io/flake-farm/actions/runs/29036655722/job/86202060288#step:7:83
A
pendingexample whose body now passes is turned by RSpec into a real failure (PendingExampleFixedError) that reds the build. ButExample#set_exceptionshort-circuited onmetadata[:pending]before reachinghandle_quarantine_check:So a fixed-pending example never consulted the quarantine list. A test you had quarantined in Trunk still failed the build, and it uploaded as a plain, un-quarantined failure (
is_quarantinedderives frommetadata[:quarantined_exception], which onlyhandle_quarantine_checksets). This is what surfaced in flake-farm:reports a fixed pending example as failurestayed red despite being quarantined.Follow-up to #1136, which fixed how these examples are classified but left the quarantine path unreached.
Fix
set_exception: let aPendingExampleFixedErrorfall through to the quarantine check. Ordinary still-failing pending examples (routed by RSpec topending_exception) are left untouched and stay green.status_and_exception: a quarantined fixed-pending has its exception swallowed, so RSpec leaves it:pending. Key onexecution_result.pending_fixed?(set by RSpec'smark_fixed!and preserved through the swallow) to still report it as afailurecarrying the fixed error — so it serializes asfailure+ quarantined rather thansuccess.handle_quarantine_check_safely: guards the case where the quarantine lookup itself fails/raises. This was already handled for normal failures, but for a pending example any exception raised insideset_exceptionwas re-fed toset_exceptionby RSpec, routed intopending_exception(which also resetspending_fixed), and the example was silently reported as a green pending. Wrapping the check so that on any error we fall back toset_exception_core(exception)makes the real failure stand (fail closed) and logs a warning instead of swallowing it.Tests
Mirrors the
variant_quarantine_spec.rbpattern in the ruby gem upload action:spec/pending_spec.rb— a fixed-pending example (pending_quarantine_test).variant_quarantine_spec.rb+pending_spec.rband asserts the run passes (both quarantined undersmoke-test-variant) — exercising the swallow path end-to-end.pending_spec.rbalone and asserts a non-zero exit, isolating the fixed-pending failure when it is not quarantined.Dylan's
test/pending_status_spec.rb(unit-level status mapping) is unchanged.Note
For the with-variant step to pass,
pending_quarantine_testmust be quarantined under variantsmoke-test-variantin staging — the same prerequisitevariant_quarantine_testalready has.Verification
rake test: 18 examples, 0 failures.run_with_trunkpath againstspec/pending_spec.rbwith a stubbed lookup:failure+ quarantined (with-variant "should pass").handle_quarantine_check_safely, no silent green).action.yamlvalidated as well-formed YAML.🤖 Generated with Claude Code