Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzwalthert committed Aug 22, 2021
1 parent 641c476 commit 325b968
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions R/prepare.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ref_install <- function(ref = "master",
)
cache_update(ref, path_pkg)
usethis::ui_done("Installed branch {ref} into {libpath[1]}.")
libpath
}
}

Expand Down
5 changes: 4 additions & 1 deletion R/testing.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ local_package <- function(pkg_name = fs::path_file(tempfile("pkg")),
withr::local_options(
usethis.quiet = TRUE,
touchstone.n_iterations = 2,
.local_envir = envir
.local_envir = envir,
touchstone.hash_source_package = tibble::tibble(
ref = character(), md5_hashes = list(), path_pkg = character()
)
)
usethis::create_package(path, open = FALSE)
withr::local_dir(path, .local_envir = if (setwd) envir else rlang::current_env())
Expand Down
16 changes: 6 additions & 10 deletions tests/testthat/test-prepare.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,13 @@ test_that("can install in isolated repos", {

test_that("cache works", {
ref <- "devel"
withr::local_options(list(
"touchstone.hash_source_package" = tibble::tibble(
ref = character(), md5_hashes = list(), path_pkg = character()
)
))
name_tmp_pkg <- "bli44"
path_pkg <- local_package(name_tmp_pkg, r_sample = "x <- 55")

expect_equal(nrow(cache_get()), 0)
expect_false(cache_up_to_date(ref, path_pkg))
cache_update(ref, path_pkg)
expect_equal(nrow(cache_get()), 1)
print(getwd())
writeLines(c("x <- 55"), "R/sample.R")
expect_true(cache_up_to_date(ref, path_pkg))
writeLines(c("22"), "R/sample.R")
Expand All @@ -54,9 +48,11 @@ test_that("cache works", {
expect_true(cache_up_to_date(ref, path_pkg))

# new root
path_pkg <- local_package(name_tmp_pkg, r_sample = "c")
cache <- cache_get()
path_pkg2 <- local_package(name_tmp_pkg, r_sample = "c")
options("touchstone.hash_source_package" = cache)
expect_equal(nrow(cache_get()), 2)
expect_false(cache_up_to_date(ref, path_pkg))
cache_update(ref, path_pkg)
expect_true(cache_up_to_date(ref, path_pkg))
expect_false(cache_up_to_date(ref, path_pkg2))
cache_update(ref, path_pkg2)
expect_true(cache_up_to_date(ref, path_pkg2))
})

0 comments on commit 325b968

Please sign in to comment.