Skip to content

Conversation

@jennybc
Copy link
Member

@jennybc jennybc commented Aug 9, 2025

Consider this late-arriving review comments on #2077

I'll make a few comments inline.

})

test_that("only returns code before subtest", {
test_that("only returns non-subtest code before subtest", {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed worth testing to me, i.e. making sure that the test_that() is not retained.

)
})

test_that("works on code like the describe() example", {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More pretty realistic usage that seems worth testing.

filter_desc(code, c("math library", "division()", "can handle division by 0"))
Condition
Error:
! Failed to find test with description "can handle division by 0".
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an FYI: the (nested) desc that identifies the targeted it() is c("math library", "division()", "can handle division by 0"). But we only mention the last component here.

#' @param desc A character vector used to filter tests. This is used to
#' (recursively) filter the content of the file, so that only the non-test
#' code up to and including the match test is run.
#' code up to and including the matching test is run.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation only applies to source_file() which is marked as internal.

The user-facing function(s?) that expose desc do not yet hint at the ability to run a nested subtest or to run an it(). I know this applies to test_file() and perhaps that is the only affected function.

@hadley hadley merged commit 8f16f26 into main Aug 9, 2025
9 of 11 checks passed
@hadley
Copy link
Member

hadley commented Aug 9, 2025

Thanks!

@hadley hadley deleted the exercise-filter-desc branch August 9, 2025 23:08
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.

3 participants