From ded0dcdc7f82c61f2ad887596a9f7261b08b4fc3 Mon Sep 17 00:00:00 2001 From: LTLA Date: Mon, 9 Sep 2024 16:20:35 -0700 Subject: [PATCH] Conditioned the symlink-related tests so that they pass on Windows. --- DESCRIPTION | 4 ++-- tests/testthat/test-storeDelayedObject.R | 29 +++++++++++++++++------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index cc32e7f..6c182c8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: alabaster.matrix Title: Load and Save Artifacts from File -Version: 1.5.6 -Date: 2024-09-03 +Version: 1.5.7 +Date: 2024-09-09 Authors@R: person("Aaron", "Lun", role=c("aut", "cre"), email="infinite.monkeys.with.keyboards@gmail.com") License: MIT + file LICENSE Description: diff --git a/tests/testthat/test-storeDelayedObject.R b/tests/testthat/test-storeDelayedObject.R index d847392..fc8e305 100644 --- a/tests/testthat/test-storeDelayedObject.R +++ b/tests/testthat/test-storeDelayedObject.R @@ -774,9 +774,21 @@ test_that("external deduplication is done correctly", { expect_identical(X, roundtrip) Y <- X + 1 - temp2 <- saveDelayed(Y, save.external.array=TRUE, external.dedup.session=dedup.session, external.dedup.action="symlink") - expect_true(file.exists(file.path(temp2, "seeds", 0))) - roundtrip <- loadDelayed(temp2, custom.takane.realize=TRUE) + temp2a <- saveDelayed(Y, save.external.array=TRUE, external.dedup.session=dedup.session, external.dedup.action="link") + expect_true(file.exists(file.path(temp2a, "seeds", 0))) + roundtrip <- loadDelayed(temp2a, custom.takane.realize=TRUE) + expect_equal(Y, roundtrip) + + if (.Platform$OS.type=="unix") { + temp2b <- saveDelayed(Y, save.external.array=TRUE, external.dedup.session=dedup.session, external.dedup.action="symlink") + expect_true(file.exists(file.path(temp2b, "seeds", 0))) + roundtrip <- loadDelayed(temp2b, custom.takane.realize=TRUE) + expect_equal(Y, roundtrip) + } + + temp2c <- saveDelayed(Y, save.external.array=TRUE, external.dedup.session=dedup.session, external.dedup.action="copy") + expect_true(file.exists(file.path(temp2c, "seeds", 0))) + roundtrip <- loadDelayed(temp2c, custom.takane.realize=TRUE) expect_equal(Y, roundtrip) Z <- DelayedArray(matrix(rpois(30, 5), ncol=5)) # checking that a different array doesn't trigger the deduplicator. @@ -787,12 +799,15 @@ test_that("external deduplication is done correctly", { if (.Platform$OS.type=="unix") { expect_identical(Sys.readlink(file.path(temp, "seeds", "0", "OBJECT")), "") - expect_true(startsWith(Sys.readlink(file.path(temp2, "seeds", "0", "OBJECT")), "/")) + expect_identical(Sys.readlink(file.path(temp2a, "seeds", "0", "OBJECT")), "") + expect_true(startsWith(Sys.readlink(file.path(temp2b, "seeds", "0", "OBJECT")), "/")) + expect_identical(Sys.readlink(file.path(temp2c, "seeds", "0", "OBJECT")), "") expect_identical(Sys.readlink(file.path(temp3, "seeds", "0", "OBJECT")), "") } }) test_that("external deduplication works with relative paths", { + skip_on_os("windows") dedup.session <- createExternalSeedDedupSession() staging <- tempfile() @@ -816,8 +831,6 @@ test_that("external deduplication works with relative paths", { roundtrip <- loadDelayed(file.path(staging, "semiclone"), custom.takane.realize=TRUE) expect_equal(Y, roundtrip) - if (.Platform$OS.type=="unix") { - expect_identical(Sys.readlink(file.path(staging, "original", "out", "seeds", "0", "OBJECT")), "") - expect_true(startsWith(Sys.readlink(file.path(staging, "semiclone", "seeds", "0", "OBJECT")), "../")) - } + expect_identical(Sys.readlink(file.path(staging, "original", "out", "seeds", "0", "OBJECT")), "") + expect_true(startsWith(Sys.readlink(file.path(staging, "semiclone", "seeds", "0", "OBJECT")), "../")) })