`redirectSource("foo", target = "foo2")` threw an error with unexpected message.
Expected match: "No such file or directory|cannot find the file"
Actual message: "path[1]=\"foo2\": Das System kann die angegebene Datei nicht finden"

test_that("redirectSource writes to config as intended", {
expect_error(redirectSource("foo", target = "foo2"), "No such file or directory|cannot find the file")
expect_identical(redirectSource("foo", target = "foo2"), normalizePath("foo2"))
expect_identical(redirectSource("foo", target = "foo3"), normalizePath("foo3"))
expect_identical(redirectSource("example", target = "example2"), normalizePath("example2"))
list(foo = normalizePath("foo3"), example = normalizePath("example2")))
fp <- fingerprint("readExample", packages = "madrat")
# ensure fingerprint is different after redirecting
nfp <- fingerprint("readExample", packages = "madrat")
# ensure original fingerprint after resetting redirection
expect_identical(fingerprint("readExample", packages = "madrat"), fp)
expect_identical(fingerprint("readExample", packages = "madrat"), nfp)
# ensure same fingerprint after redirecting to the same target again
test_that("redirectSource symlinks other files", {
redirectSource("Example", target = target, linkOthers = FALSE)
}, "cannot open file 'Example2.txt': No such file or directory", fixed = TRUE)
test_that("scope for redirectSource can be set", {
redirectSource("tau", target = "tau2", local = FALSE)
test_that("redirect target can be files", {
localConfig(redirections = list(), sourcefolder = withr::local_tempdir())
redirectSource("Example", target = c("Example.txt", "Example2.txt"), local = local)
sourceFolder <- normalizePath(getSourceFolder("Example", subtype = NULL))
# temporary sourcefolder should only exist while executing f, after f returned it should be deleted
# not local, so temporary sourcefolder should exist until the R session closes
redirectSource("Example", target = c(`some/subfolder/Example.txt` = "Example.txt"))
redirectSource("Example", target = c("some/subfolder/" = "Example.txt"))
test_that("caching works with redirectSource", {
localConfig(sourcefolder = withr::local_tempdir(), cachefolder = withr::local_tempdir())
test_that("redirectSource symlinks all other files", {
sourceFolder <- getSourceFolder("Example", subtype = NULL)
dir.create(file.path(sourceFolder, dirname(p)), showWarnings = FALSE, recursive = TRUE)
redirectedSourceFolder <- redirectSource("Example", target = c(`x.txt` = target))
redirectedSourceFolder <- redirectSource("Example", target = c(`B/B2/b.txt` = target))