Skip to content

Commit

Permalink
Fix a test case
Browse files Browse the repository at this point in the history
Need to find the packages root in `R CMD check` as well.
  • Loading branch information
gaborcsardi committed Mar 17, 2024
1 parent bee893b commit 2994ae6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,21 @@ test_temp_dir <- function(pattern = "test-dir-", envir = parent.frame()) {
}

httpbin <- webfakes::new_app_process(webfakes::httpbin_app())

test_package_root <- function() {
x <- tryCatch(
rprojroot::find_package_root_file(),
error = function(e) NULL)

if (!is.null(x)) return(x)

pkg <- testthat::testing_package()
x <- tryCatch(
rprojroot::find_package_root_file(
path = file.path("..", "..", "00_pkg_src", pkg)),
error = function(e) NULL)

if (!is.null(x)) return(x)

stop("Cannot find package root")
}
2 changes: 1 addition & 1 deletion tests/testthat/test-script.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ test_that("install-github.R script is up to date", {
tmp <- test_temp_file(".R")

withr::with_dir(
rprojroot::find_package_root_file(),
test_package_root(),
brew::brew(file.path(root, "install-github.Rin"), tmp))

expect_equal(
Expand Down

0 comments on commit 2994ae6

Please sign in to comment.