Skip to content

Commit b2136ff

Browse files
committed
Use run_dontrun and run_donttest
1 parent 202ea81 commit b2136ff

3 files changed

Lines changed: 28 additions & 14 deletions

File tree

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# devtools (development version)
22

3+
* `run_examples()` arguments `run` and `test` are deprecated in favor of the (hopefully) more clear `run_dontrun` and `run_donttest` (pkgload/#107).
4+
35
# devtools 2.3.0
46

57
* `build()` now errors with a more informative error message when passed an

R/run-examples.R

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@
66
#' making it possible to run all examples from an R function.
77
#'
88
#' @template devtools
9+
#' @inheritParams pkgload::run_example
910
#' @param start Where to start running the examples: this can either be the
1011
#' name of `Rd` file to start with (with or without extensions), or
1112
#' a topic name. If omitted, will start with the (lexicographically) first
1213
#' file. This is useful if you have a lot of examples and don't want to
1314
#' rerun them every time you fix a problem.
1415
#' @family example functions
1516
#' @param show DEPRECATED.
16-
#' @param test if `TRUE`, code in \code{\\donttest{}} will be commented
17-
#' out. If `FALSE`, code in \code{\\testonly{}} will be commented out.
18-
#' @param run if `FALSE`, code in \code{\\dontrun{}} will be commented
19-
#' out.
2017
#' @param fresh if `TRUE`, will be run in a fresh R session. This has
2118
#' the advantage that there's no way the examples can depend on anything in
2219
#' the current session, but interactive code (like [browser()])
@@ -25,8 +22,18 @@
2522
#' examples are updated before running them.
2623
#' @keywords programming
2724
#' @export
28-
run_examples <- function(pkg = ".", start = NULL, show = TRUE, test = FALSE,
29-
run = FALSE, fresh = FALSE, document = TRUE) {
25+
run_examples <- function(pkg = ".", start = NULL, show = TRUE, run_donttest = FALSE,
26+
run_dontrun = FALSE, fresh = FALSE, document = TRUE, run, test) {
27+
28+
if (!missing(run)) {
29+
warning("`run_examples(run=)` is deprecated, please use `run_example(run_dontrun=)` instead", call. = FALSE)
30+
run_dontrun <- run
31+
}
32+
if (!missing(test)) {
33+
warning("`run_examples(test=)` is deprecated, please use `run_example(run_donttest=)` instead", call. = FALSE)
34+
run_donttest <- test
35+
}
36+
3037
pkg <- as.package(pkg)
3138

3239
if (fresh) {
@@ -60,7 +67,7 @@ run_examples <- function(pkg = ".", start = NULL, show = TRUE, test = FALSE,
6067
load_all(pkg$path, reset = TRUE, export_all = FALSE)
6168
on.exit(load_all(pkg$path, reset = TRUE))
6269

63-
lapply(files, pkgload::run_example, test = test, run = run)
70+
lapply(files, pkgload::run_example, run_donttest = run_donttest, run_dontrun = run_dontrun)
6471

6572
invisible()
6673
}

man/run_examples.Rd

Lines changed: 12 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)