Skip to content

Commit

Permalink
Merge pull request #128 from mrc-ide/mrc-5120
Browse files Browse the repository at this point in the history
Allow 'here' in dependencies to have trailing slash
  • Loading branch information
weshinsley authored Mar 19, 2024
2 parents 490391b + 8b64719 commit f896c9e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions R/outpack_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ plan_copy_files <- function(root, id, there, here, call = NULL) {
expanded <- lapply(which(is_dir), function(i) {
p <- there[[i]]
j <- string_starts_with(p, files)
set_names(files[j],
file.path(here[[i]], string_drop_prefix(p, files[j])))
nms <- file.path(sub("/+$", "", here[[i]]),
string_drop_prefix(p, files[j]))
set_names(files[j], nms)
})

there <- replace_ragged(there, is_dir, lapply(expanded, unname))
Expand Down
23 changes: 23 additions & 0 deletions tests/testthat/test-run.R
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,29 @@ test_that("can depend on a directory artefact", {
})


test_that("can depend on a directory artefact with trailing slash", {
path <- test_prepare_orderly_example("directories")
envir1 <- new.env()
id1 <- orderly_run_quietly("directories", root = path, envir = envir1)

path_src <- file.path(path, "src", "use")
fs::dir_create(path_src)
writeLines(c(
'orderly2::orderly_dependency("directories", "latest()", "output/")',
'orderly2::orderly_artefact("data", "d.rds")',
'd <- c(readRDS("output/a.rds", "output/b.rds"))',
'saveRDS(d, "d.rds")'),
file.path(path_src, "orderly.R"))
envir2 <- new.env()
id2 <- orderly_run_quietly("use", root = path, envir = envir2)
meta <- orderly_metadata(id2, root = path)
expect_equal(meta$depends$packet, id1)
expect_equal(meta$depends$files[[1]],
data_frame(here = c("output/a.rds", "output/b.rds"),
there = c("output/a.rds", "output/b.rds")))
})


test_that("can compute dependencies", {
path <- test_prepare_orderly_example("parameters")
envir1 <- new.env()
Expand Down

0 comments on commit f896c9e

Please sign in to comment.