Repository navigation
Make desc filtering more flexible and support it in test_dir() - #2379
Open
MichaelChirico wants to merge 3 commits into
Open
MichaelChirico wants to merge 3 commits into
MichaelChirico wants to merge 3 commits into
Conversation
* Match `desc` via fixed substring matching (`grepl(..., fixed = TRUE)`) rather than exact equality, and allow zero or multiple matches instead of erroring. * Support `desc` in `test_dir()`, `test_local()`, `test_package()`, `test_check()`, `source_dir()`, and parallel test execution, skipping files with zero matches before invoking reporters. * Update `SnapshotReporter` to clear old snapshots per executed test in `start_test()` when `desc` is active and to skip `snapshot_cleanup()` in `end_reporter()`, preventing snapshot duplication or deletion of untouched file snapshots. Closes r-lib#2328
- Preserve untouched tests in .new.md under desc filtering by seeding new_snaps alongside cur_snaps and resetting new_snaps on skip/error - Lazily seed non-default snapshot variants in take_snapshot() so untouched variant files (e.g. other OS / R versions) are never modified, preserving snapshots for skipped/errored tests via tests_reset - Pre-filter test_paths by desc in test_dir() before spawning parallel workers so 0-1 matching files run serially - Validate desc up front in source_dir() and test_dir()
This branch has not been deployed
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.
Closes #2328; written by Gemini. The tests look roughly correct to me, though I don't follow the internals of snapshotting too too well; and the R/ implementation also makes sense, though I am even less familiar with any subtleties to be on the watch for there.
descvia fixed substring matching (grepl(..., fixed = TRUE)) rather than exact equality, and allow zero or multiple matches instead of erroring.descintest_dir(),test_local(),test_package(),test_check(),source_dir(), and parallel test execution, skipping files with zero matches before invoking reporters.SnapshotReporterto clear old snapshots per executed test instart_test()whendescis active and to skipsnapshot_cleanup()inend_reporter(), preventing snapshot duplication or deletion of untouched file snapshots.Here is also a minimal end-to-end example using
--test_filterto demonstrate how that workflow looks likeMODULE.bazel
BUILD.bazel
tests/testthat.R (
chmod +x; for an installed R package, replacetest_dir(...)withtest_check("mypkg", desc = if (nzchar(desc)) desc))tests/testthat/test-math.R
tests/testthat/test-strings.R
Verified Bazel Runs