Refactor the test_examples function#532
Conversation
hadley
left a comment
There was a problem hiding this comment.
Is there a simple way to test this code?
(Also needs a news bullet)
| #' @param path For \code{test_examples}, path to the package directory. | ||
| #' For \code{test_example}, path to a single Rd file. Remember the working | ||
| #' directory for tests is \code{tests/testthat}. | ||
| #' @param rd A parsed Rd object, obtained from \code{\link[tools]{Rd_db}}. |
| test_examples <- function(path = "../../man") { | ||
| man <- dir(path, "\\.Rd$", full.names = TRUE) | ||
| lapply(man, test_example) | ||
| test_examples <- function(path = "../..") { |
There was a problem hiding this comment.
I think this would be clearer with two functions - maybe test_examples_installed and test_examples_source ?
There was a problem hiding this comment.
Ok I split it up, I agree the logic is more clear now
This can then be used by `test_examples()` to find the examples for the package being tested.
Previously it would never run examples during R CMD check because there was no '/man' directory for installed packages. This instead uses tools::Rd_db to parse the Rd files into a database and uses that directly, which does work for installed packages.
6b032ab to
9023d3c
Compare
[ci-skip]
|
I haven't come up with a good way to test this, since we don't have a source package when using |
|
Thanks! |
Previously it would never run examples during R CMD check because there
was no '/man' directory for installed packages. This instead uses
tools::Rd_db to parse the Rd files into a database and uses that
directly, which does work for installed packages.
Fixes r-lib/covr#205