-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for test files in nested directories #1850
base: main
Are you sure you want to change the base?
Conversation
Give test_dir() a recursive option (r-lib#1605) The recursive argument allows test files in nested directories.
Hi @hadley, would you have time to review this PR for the 3.2.2 release? Thanks! |
@radbasa this feels like a big change, so it'd need to wait for the next minor release, sorry. |
find_test_scripts <- function(path, filter = NULL, invert = FALSE, ..., full.names = TRUE, start_first = NULL, recursive = FALSE) { | ||
files <- dir(path, "^test.*\\.[rR]$", full.names = full.names, recursive = recursive) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hadley , understood. We'll wait for the next release.
If you don't mind, I'm leaving this here as a note for when you have the time to review this pull request.
This is the only significant change to the {testthat}
code. It's a simple use of the recursive
flag parameter of the dir()
function. The rest of the logical/functional changes are to expose the recursive
flag to the relevant external facing functions.
The rest of the PR are unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the code change is small, but the implications are large. For example, off the top of my head, how does this affect snapshot tests? Do they end up in the right place?
Closes #1605
Allows the use of directories to organize test files.
The
recursive
argument is optional and defaults toFALSE
.testthat::test_dir("tests/testthat/")
will work as before. Just one single directory, and with the default reporter.testthat::test_dir("tests/testthat/", recursive = TRUE)
to run all of the test scripts in all directories intests/testthat/
.testthat::test_dir()
will still only see test scripts with^test.*\\.[rR]$
filenames.