diff --git a/R/cacheName.R b/R/cacheName.R index c1ba960..bb7b855 100644 --- a/R/cacheName.R +++ b/R/cacheName.R @@ -78,9 +78,14 @@ cacheName <- function(prefix, type, args = NULL, graph = NULL, mode = "put", pa vcat(3, " - Search pattern ", basename(.fname(prefix, type, "-F*", args)), show_prefix = FALSE) return(NULL) } - if (length(files) == 1) file <- files - else file <- files[robustOrder(paste(file.mtime(files), basename(files)), decreasing = TRUE)][1] - vcat(1, " - forced cache does not match fingerprint ", fp, - fill = 300, show_prefix = FALSE) + if (length(files) == 1) { + file <- files + } else { + file <- files[robustOrder(paste(file.mtime(files), basename(files)), decreasing = TRUE)][1] + } + if (!isWrapperActive("pucAggregate")) { + vcat(1, " - forced cache does not match fingerprint ", fp, + fill = 300, show_prefix = FALSE) + } return(file) } diff --git a/R/isWrapperActive.R b/R/isWrapperActive.R index c362ae6..2d81241 100644 --- a/R/isWrapperActive.R +++ b/R/isWrapperActive.R @@ -30,6 +30,7 @@ setWrapperInactive <- function(name) { readSource = FALSE, calcOutput = FALSE, retrieveData = FALSE, + pucAggregate = FALSE, saveCache = FALSE, callingHandler = FALSE, vcat = FALSE, diff --git a/R/pucAggregate.R b/R/pucAggregate.R index 1b8a7dc..4ba387f 100644 --- a/R/pucAggregate.R +++ b/R/pucAggregate.R @@ -34,6 +34,9 @@ #' @export pucAggregate <- function(puc, regionmapping = getConfig("regionmapping"), ..., renv = TRUE, strict = FALSE) { argumentValues <- c(as.list(environment()), list(...)) # capture arguments for logging + + setWrapperActive("pucAggregate") + extraArgs <- list(...) startinfo <- toolstartmessage("pucAggregate", argumentValues, "+") puc <- normalizePath(puc) diff --git a/tests/testthat/test-puc.R b/tests/testthat/test-puc.R index 7a3a4af..cda95d0 100644 --- a/tests/testthat/test-puc.R +++ b/tests/testthat/test-puc.R @@ -1,22 +1,22 @@ test_that("puc creation works", { - skip_on_cran() - retrieveData("example", rev = 42, extra = "test1") - expect_true(dir.exists(getConfig("pucfolder"))) - withr::local_dir(getConfig("pucfolder")) - expect_true(file.exists("rev42_extra_example_tag.puc")) - untar("rev42_extra_example_tag.puc") - expect_true(length(Sys.glob("calcTauTotal*.rds")) == 1) - cfg <- readRDS("config.rds") - expect_identical(cfg$package, "madrat") - expect_identical(cfg$pucArguments, "extra") - expect_identical(cfg$args, list(model = "example", rev = 42, dev = "", cachetype = "def", - puc = TRUE, strict = FALSE, extra = "test1")) - expect_error(pucAggregate("rev42_extra_example_tag.puc", bla = "blub"), "cannot be changed in the given puc") - expect_message(pucAggregate("rev42_extra_example_tag.puc", extra = "blub", regionmapping = "regionmappingH12.csv", - renv = FALSE), "Run calcOutput") - expect_message(pucAggregate("rev42_extra_example_tag.puc", extra = "blub", regionmapping = "regionmappingH12.csv", - renv = FALSE), "already available") - expect_true(file.exists(file.path(getConfig("outputfolder"), "rev42_h12_7a5441e5_example_customizable_tag.tgz"))) - expect_message(retrieveData("example", rev = 42, extra = "test2", renv = FALSE), "Run pucAggregate") - expect_true(file.exists(file.path(getConfig("outputfolder"), "rev42_h12_5f3d77a0_example_customizable_tag.tgz"))) + skip_on_cran() + retrieveData("example", rev = 42, extra = "test1") + expect_true(dir.exists(getConfig("pucfolder"))) + withr::local_dir(getConfig("pucfolder")) + expect_true(file.exists("rev42_extra_example_tag.puc")) + untar("rev42_extra_example_tag.puc") + expect_true(length(Sys.glob("calcTauTotal*.rds")) == 1) + cfg <- readRDS("config.rds") + expect_identical(cfg$package, "madrat") + expect_identical(cfg$pucArguments, "extra") + expect_identical(cfg$args, list(model = "example", rev = 42, dev = "", cachetype = "def", + puc = TRUE, strict = FALSE, extra = "test1")) + expect_error(pucAggregate("rev42_extra_example_tag.puc", bla = "blub"), "cannot be changed in the given puc") + expect_message(pucAggregate("rev42_extra_example_tag.puc", extra = "blub", regionmapping = "regionmappingH12.csv", + renv = FALSE), "Run calcOutput") + expect_message(pucAggregate("rev42_extra_example_tag.puc", extra = "blub", regionmapping = "regionmappingH12.csv", + renv = FALSE), "already available") + expect_true(file.exists(file.path(getConfig("outputfolder"), "rev42_h12_7a5441e5_example_customizable_tag.tgz"))) + expect_message(retrieveData("example", rev = 42, extra = "test2", renv = FALSE), "Run pucAggregate") + expect_true(file.exists(file.path(getConfig("outputfolder"), "rev42_h12_5f3d77a0_example_customizable_tag.tgz"))) })