Skip to content

718: Make interval range warning test robust to repeated runs - #1247

Merged
nikosbosse merged 4 commits into
mainfrom
issue-718-repeat-test-warning
Nov 8, 2026
Merged

nikosbosse merged 4 commits into
mainfrom
issue-718-repeat-test-warning

Conversation

@nikosbosse

@nikosbosse nikosbosse commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

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. calling devtools::test() twice) therefore made the test fail.

This PR changes only the test, not the package code:

  • Check the once-per-session behaviour. With options(rlib_warning_verbosity = "default"), the test calls assert_input_interval() once inside suppressWarnings() 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.
  • Check the warning content. The test then sets 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.
  • The original option value is restored with on.exit(options(old_options), add = TRUE). Only base options() is used, so nothing is added to Suggests (rlang and withr are not declared dependencies).
  • Add a NEWS item under "Internal changes".

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:

    • this PR's test: 0 failures on run 1, 0 failures on run 2;
    • the original test from main: 0 failures on run 1, 1 failure on run 2 (the Testing fails locally when done repeatedly #718 bug);
    • this PR's test with the verbose override removed: fails on run 1;
    • this PR's test against package code with .frequency = "once" changed to "always": fails on run 1 (the expect_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. Ran lintr::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:

  • Coverage of .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 suggested rlang::reset_warning_verbosity(), which would have needed rlang in Suggests. The suppressWarnings() + expect_no_warning() pair needs no new dependency and is deterministic whatever the session state.
  • Loop with an unused index (nit). Replaced for (i in 1:2) with two explicit expect_warning() calls.

Not changed, with reasons:

  • withr::local_options() instead of base options() + 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.
  • NEWS heading for a test-only change (nit). The project's PR rules require a news item. The reviewer agreed the wording is accurate, so no change was needed.

🤖 Generated with Claude Code

nikosbosse and others added 4 commits November 8, 2026 13:09
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

codecov Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.18%. Comparing base (8b18f07) to head (f3e77a0).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nikosbosse
nikosbosse marked this pull request as ready for review November 8, 2026 13:32
@nikosbosse

Copy link
Copy Markdown
Collaborator Author

Merging directly since it's very low-impact

@nikosbosse
nikosbosse merged commit fe06be3 into main Nov 8, 2026
11 checks passed
@nikosbosse
nikosbosse deleted the issue-718-repeat-test-warning branch November 8, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Testing fails locally when done repeatedly

1 participant