Skip to content

Commit

Permalink
Merge pull request #224 from jmbarbone/183-read-xlsx-seed
Browse files Browse the repository at this point in the history
resolves #183
  • Loading branch information
ycphs authored Jul 11, 2021
2 parents 89ce583 + 6abdeeb commit a4f9b83
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 1 addition & 3 deletions R/readWorkbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,8 @@ read.xlsx.default <- function(
rows <- as.integer(sort(rows))
}

xmlDir <-
file.path(tempdir(), paste0(sample(LETTERS, 10), collapse = ""), "_excelXMLRead")
xmlDir <- paste0(tempfile(), "_excelXMLRead")
xmlFiles <- unzip(xlsxFile, exdir = xmlDir)

on.exit(unlink(xmlDir, recursive = TRUE), add = TRUE)

sharedStringsFile <- grep("sharedStrings.xml$", xmlFiles, perl = TRUE, value = TRUE)
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-read_xlsx_random_seed.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
test_that("read_xlsx() does not change random seed", {
rs <- .Random.seed
expect_identical(rs, .Random.seed)
tf <- temp_xlsx()
expect_identical(rs, .Random.seed)
write.xlsx(data.frame(a = 1), tf)
expect_identical(rs, .Random.seed)
read.xlsx(tf)
expect_identical(rs, .Random.seed)
unlink(tf)
})

0 comments on commit a4f9b83

Please sign in to comment.