Skip to content

Commit

Permalink
Only use load_helpers and encoding for devel / unreleased testthat.
Browse files Browse the repository at this point in the history
Fixes #1503
  • Loading branch information
jimhester committed May 12, 2017
1 parent c071299 commit c382a24
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# devtools 1.13.1

* Fix `test()` compatibility with testthat versions 1.0.2 (#1503).

# devtools 1.13.0

## New Features
Expand Down
14 changes: 8 additions & 6 deletions R/test.r
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ test <- function(pkg = ".", filter = NULL, ...) {
Sys.sleep(0.05); utils::flush.console() # Avoid misordered output in RStudio

env <- new.env(parent = ns_env)
withr::with_envvar(r_env_vars(), testthat::test_dir(test_path, filter = filter,
env = env,
...,
load_helpers = FALSE,
encoding = pkg$encoding %||% "unknown")
)

testthat_args <- list(test_path, filter = filter, env = env, ... = ...)
if (packageVersion("testthat") > "1.0.2") {
testthat_args <- c(testthat_args, load_helpers = FALSE, encoding = pkg$encoding %||% "unknown")
}

withr::with_envvar(r_env_vars(),
do.call(testthat::test_dir, testthat_args))
}

find_test_dir <- function(path) {
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-test.r
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ test_that("Package can be tested with testthat not on search path", {
test("testTestWithDepends", reporter = "stop")
expect_true(TRUE)
})

test_that("Filtering works with devtools::test", {
test("testTest", filter = "dummy", reporter = "stop")
expect_true(TRUE)
})

0 comments on commit c382a24

Please sign in to comment.