Skip to content

Commit

Permalink
Create temporaty directory in dir: test/testthat
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunuuuu committed Jan 27, 2024
1 parent c83e892 commit 3a6f3c7
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 11 deletions.
1 change: 0 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ jobs:
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Creating temporary directory
tmpdir <- testthat::test_path("_TEMP")
if (!dir.exists(tmpdir)) dir.create(tmpdir)
tmpdir <- normalizePath(tmpdir, mustWork = TRUE)
2 changes: 2 additions & 0 deletions tests/testthat/teardown.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Removing temporary directory
if (dir.exists(tmpdir)) unlink(tmpdir, recursive = TRUE)
2 changes: 1 addition & 1 deletion tests/testthat/test_Convert.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mat <- mock_matrix(2000, 200)
path <- normalizePath(tempfile(), mustWork = FALSE)
path <- normalizePath(tempfile(tmpdir = tmpdir), mustWork = FALSE)
obj <- BPCells::write_matrix_dir(mat = as(mat, "dgCMatrix"), dir = path)
obj <- BPCells::convert_matrix_type(obj, "uint32_t")

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_Dir.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mat <- mock_matrix(2000, 200)
path <- normalizePath(tempfile(), mustWork = FALSE)
path <- normalizePath(tempfile(tmpdir = tmpdir), mustWork = FALSE)
obj <- BPCells::write_matrix_dir(mat = as(mat, "dgCMatrix"), dir = path)

testthat::test_that("`BPCellsDirSeed()` works as expected", {
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_HDF5.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mat <- mock_matrix(2000, 200)
path <- normalizePath(tempfile(), mustWork = FALSE)
path <- normalizePath(tempfile(tmpdir = tmpdir), mustWork = FALSE)
obj <- BPCells::write_matrix_hdf5(
mat = as(mat, "dgCMatrix"),
path = path, group = "BPCells"
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_Mask.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mat <- mock_matrix(2000, 200)
path <- normalizePath(tempfile(), mustWork = FALSE)
path <- normalizePath(tempfile(tmpdir = tmpdir), mustWork = FALSE)
obj <- BPCells::write_matrix_dir(mat = as(mat, "dgCMatrix"), dir = path)
mask <- matrix(
sample(c(0, 1),
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_Multiply.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mat <- mock_matrix(2000, 200)
mat2 <- mock_matrix(ncol(mat), 5000)
path <- normalizePath(c(tempfile(), tempfile()), mustWork = FALSE)
path <- normalizePath(c(tempfile(tmpdir = tmpdir), tempfile(tmpdir = tmpdir)), mustWork = FALSE)
obj <- BPCells::write_matrix_dir(mat = as(mat, "dgCMatrix"), dir = path[1L])
obj2 <- BPCells::write_matrix_dir(mat = as(mat2, "dgCMatrix"), dir = path[2L])
obj <- obj %*% obj2
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_RankTransform.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mat <- mock_matrix(2000, 200)
path <- normalizePath(tempfile(), mustWork = FALSE)
path <- normalizePath(tempfile(tmpdir = tmpdir), mustWork = FALSE)
obj <- BPCells::write_matrix_dir(mat = as(mat, "dgCMatrix"), dir = path)
obj <- BPCells:::rank_transform(obj, "col")

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_RenameDims.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mat <- mock_matrix(2000, 200)
path <- normalizePath(tempfile(), mustWork = FALSE)
path <- normalizePath(tempfile(tmpdir = tmpdir), mustWork = FALSE)
obj <- BPCells::write_matrix_dir(mat = as(mat, "dgCMatrix"), dir = path)
dimnames(obj) <- list(
paste0("G", seq_len(2000L)),
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_Subset.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mat <- mock_matrix(2000, 200)
path <- normalizePath(tempfile(), mustWork = FALSE)
path <- normalizePath(tempfile(tmpdir = tmpdir), mustWork = FALSE)
obj <- BPCells::write_matrix_dir(mat = as(mat, "dgCMatrix"), dir = path)
obj <- obj[1:1000L, 1:100]

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_cBindMatrix.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mat1 <- mock_matrix(2000, 200)
mat2 <- mock_matrix(2000, 200)
path <- normalizePath(c(tempfile(), tempfile()), mustWork = FALSE)
path <- normalizePath(c(tempfile(tmpdir = tmpdir), tempfile(tmpdir = tmpdir)), mustWork = FALSE)
obj1 <- BPCells::write_matrix_dir(mat = as(mat1, "dgCMatrix"), dir = path[1L])
obj2 <- BPCells::write_matrix_dir(mat = as(mat2, "dgCMatrix"), dir = path[2L])
obj <- cbind(obj1, obj2)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_rBindMatrix.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mat <- mock_matrix(2000, 200)
mat2 <- mock_matrix(2000, 200)
path <- normalizePath(c(tempfile(), tempfile()), mustWork = FALSE)
path <- normalizePath(c(tempfile(tmpdir = tmpdir), tempfile(tmpdir = tmpdir)), mustWork = FALSE)
mat <- BPCells::write_matrix_dir(mat = as(mat, "dgCMatrix"), dir = path[1L])
mat2 <- BPCells::write_matrix_dir(mat = as(mat2, "dgCMatrix"), dir = path[2L])
obj <- rbind(mat, mat2)
Expand Down

0 comments on commit 3a6f3c7

Please sign in to comment.