From 9d25077ba9ef1b2eea9b3714800289e090aa5ecb Mon Sep 17 00:00:00 2001 From: David Blodgett Date: Thu, 19 Dec 2024 22:07:51 -0600 Subject: [PATCH] clean up after sample data --- tests/testthat/test-compat.R | 7 ++++++- tests/testthat/test-get.R | 5 +++++ tests/testthat/test-utils.R | 7 ++++++- vignettes/basics.Rmd | 5 +++++ vignettes/parallel.Rmd | 6 ++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-compat.R b/tests/testthat/test-compat.R index 1401912..fd57496 100644 --- a/tests/testthat/test-compat.R +++ b/tests/testthat/test-compat.R @@ -1,5 +1,8 @@ library(pizzarr) +sample_dir <- tools::R_user_dir("pizzarr") +clean <- !dir.exists(sample_dir) + test_that("Can open Zarr group using convenience function", { root <- pizzarr_sample(file.path("fixtures", "v2", "data.zarr")) @@ -513,4 +516,6 @@ test_that("Can create 0-element 2D array", { expect_equal(is.character(sel$data), TRUE) expect_equal(length(sel$data), 0) expect_equal(dim(sel$data), c(0, 0)) -}) \ No newline at end of file +}) + +if(clean) unlink(sample_dir, recursive = TRUE) diff --git a/tests/testthat/test-get.R b/tests/testthat/test-get.R index 5066d6b..cc934c0 100644 --- a/tests/testthat/test-get.R +++ b/tests/testthat/test-get.R @@ -1,5 +1,8 @@ library(pizzarr) +sample_dir <- tools::R_user_dir("pizzarr") +clean <- !dir.exists(sample_dir) + test_that("get_basic_selection_zd", { # Reference: https://github.com/zarr-developers/zarr-python/blob/5dd4a0e6cdc04c6413e14f57f61d389972ea937c/zarr/tests/test_indexing.py#L70 a <- as_scalar(42) @@ -270,3 +273,5 @@ test_that("Can read 2D string array", { expected_arr <- t(array(data = c(row1, row2, row3, row4, row5), dim = c(10, 5))) expect_equal(expected_arr, data) }) + +if(clean) unlink(sample_dir, recursive = TRUE) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 3a92b79..98f6655 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -1,5 +1,8 @@ library(pizzarr) +sample_dir <- tools::R_user_dir("pizzarr") +clean <- !dir.exists(sample_dir) + test_that("demo data", { demo_data <- pizzarr_sample() @@ -215,4 +218,6 @@ test_that("NaN in json", { expect_equal(check, list(name = NULL)) expect_warning(try_fromJSON("borked", "test warning"), "test warning") -}) \ No newline at end of file +}) + +if(clean) unlink(sample_dir, recursive = TRUE) \ No newline at end of file diff --git a/vignettes/basics.Rmd b/vignettes/basics.Rmd index 4e47eb3..b205a08 100644 --- a/vignettes/basics.Rmd +++ b/vignettes/basics.Rmd @@ -13,6 +13,8 @@ vignette: > comment = "#>", out.width = "100%" ) +sample_dir <- tools::R_user_dir("pizzarr") +clean <- !dir.exists(sample_dir) ``` ## Load the package @@ -123,3 +125,6 @@ class(a) a$get_attrs()$to_list() ``` +```{r, include=FALSE} +if(clean) unlink(sample_dir, recursive = TRUE) +``` \ No newline at end of file diff --git a/vignettes/parallel.Rmd b/vignettes/parallel.Rmd index 7956d9e..8209633 100644 --- a/vignettes/parallel.Rmd +++ b/vignettes/parallel.Rmd @@ -14,6 +14,8 @@ vignette: > out.width = "100%" ) library(pizzarr) +sample_dir <- tools::R_user_dir("pizzarr") +clean <- !dir.exists(sample_dir) ``` By default, reads and writes are performed sequentially (i.e., not in parallel). @@ -138,4 +140,8 @@ To re-enable, run: ```{r} pbapply::pboptions(type = "timer") +``` + +```{r, include=FALSE} +if(clean) unlink(sample_dir, recursive = TRUE) ``` \ No newline at end of file