Repository navigation
718: Make interval range warning test robust to repeated runs - #1247
Merged
Merged
Conversation
The warning about interval ranges between 0 and 1 is only shown once per session by design, so expect_warning() failed on the second run of the test suite in the same session. Force rlang to show the warning every time within the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Calling assert_input_interval() twice makes the test fail within a single run if the verbosity override is removed, so CI guards the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Address review: check that a repeated call is silent at default verbosity, so the .frequency = "once" behaviour stays covered, and replace the loop with two explicit expect_warning() calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1247 +/- ##
=======================================
Coverage 99.18% 99.18%
=======================================
Files 41 41
Lines 2333 2333
=======================================
Hits 2314 2314
Misses 19 19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
nikosbosse
marked this pull request as ready for review
November 8, 2026 13:32
Collaborator
Author
|
Merging directly since it's very low-impact |
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.
CLAUDE: ## Description
This PR closes #718.
The test "assert_input_interval() works as expected" checks for the warning "Found interval ranges between 0 and 1. Are you sure that's right?". That warning is raised with
.frequency = "once", so rlang shows it only once per R session. Running the test suite a second time in the same session (e.g. callingdevtools::test()twice) therefore made the test fail.This PR changes only the test, not the package code:
options(rlib_warning_verbosity = "default"), the test callsassert_input_interval()once insidesuppressWarnings()and then expects the next call to give no warning (expect_no_warning()). This holds whether or not the warning was already shown earlier in the session, so the check is deterministic. It fails if.frequency = "once"is ever dropped.options(rlib_warning_verbosity = "verbose"), rlang's documented override that makes.frequency = "once"warnings show every time, and expects the warning on two consecutive calls. If the override stops working, the second call gets no warning and the test fails on the very first run in a fresh session, so CI guards the fix without anyone running the suite twice.on.exit(options(old_options), add = TRUE). Only baseoptions()is used, so nothing is added to Suggests (rlang and withr are not declared dependencies).The test keeps running everywhere. That is a stronger fix than skipping it locally, which the issue discussion also suggested.
Implementation: a judge agent compared two independent drafts and chose draft B as the base. The repeated-call check came from draft A.
Checklist
My PR is based on a package issue and I have explicitly linked it.
I have included the target issue or issues in the PR title as follows: issue-number: PR title
I have tested my changes locally. Each variant was run with
testthat::test_file()twice in a single fresh R session:main: 0 failures on run 1, 1 failure on run 2 (the Testing fails locally when done repeatedly #718 bug);verboseoverride removed: fails on run 1;.frequency = "once"changed to"always": fails on run 1 (theexpect_no_warning()check).The full suite (
devtools::test()) passes:[ FAIL 0 | WARN 4 | SKIP 0 | PASS 1044 ].I have added or updated unit tests where necessary. The test fails before the change (on a repeated run) and passes after it, as shown above.
I have updated the documentation if required. N/A: this is a test-only change and no user-facing documentation is affected.
I have built the package locally and run rebuilt docs using roxygen2. N/A: there are no roxygen or R/ changes, so there is nothing to rebuild.
My code follows the established coding standards and I have run
lintr::lint_package()to check for style issues introduced by my changes. Ranlintr::lint()on the changed test file: no lints.I have added a news item linked to this PR.
I have reviewed CI checks for this PR and addressed them as far as I am able. CI is pending.
Review
An independent adversarial agent reviewed this PR. Its verdict was "approve". It also made the findings below.
Changed in response:
.frequency = "once"(minor). Forcing verbose output meant no test covered the once-per-session behaviour any more. The PR now adds a check at default verbosity that a repeated call is silent. The reviewer suggestedrlang::reset_warning_verbosity(), which would have needed rlang in Suggests. ThesuppressWarnings()+expect_no_warning()pair needs no new dependency and is deterministic whatever the session state.for (i in 1:2)with two explicitexpect_warning()calls.Not changed, with reasons:
withr::local_options()instead of baseoptions()+on.exit()(nit). withr is not a declared dependency, and no test in the repo uses it. The reviewer also said no change was needed.🤖 Generated with Claude Code