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

Refactor the test_examples function #532

Merged
merged 6 commits into from Oct 1, 2017

Conversation

Projects
None yet
2 participants
@jimhester
Member

jimhester commented Oct 6, 2016

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

@hadley

Is there a simple way to test this code?

(Also needs a news bullet)

#' 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}}.

This comment has been minimized.

@hadley

hadley Dec 15, 2016

Member

"or otherwise"

test_examples <- function(path = "../../man") {
man <- dir(path, "\\.Rd$", full.names = TRUE)
lapply(man, test_example)
test_examples <- function(path = "../..") {

This comment has been minimized.

@hadley

hadley Dec 15, 2016

Member

I think this would be clearer with two functions - maybe test_examples_installed and test_examples_source ?

This comment has been minimized.

@jimhester

jimhester Dec 30, 2016

Member

Ok I split it up, I agree the logic is more clear now

jimhester added some commits Oct 6, 2016

Add the package name to the test environment
This can then be used by `test_examples()` to find the examples for the
package being tested.
Refactor the test_examples function
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.
Fix external link
[ci-skip]
@jimhester

This comment has been minimized.

Member

jimhester commented Dec 30, 2016

I haven't come up with a good way to test this, since we don't have a source package when using R CMD check there isn't a great way to test running source examples. The current test runs the the code to find the examples, but does not actually run them. The main issue with running them is the examples contain expectations themselves, which makes the reporting a little confusing. They also have additional output that would need to be suppressed using something like withr::with_output_sink().

@hadley hadley merged commit 4438b21 into r-lib:master Oct 1, 2017

0 of 2 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@hadley

This comment has been minimized.

Member

hadley commented Oct 1, 2017

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment