diff --git a/tests/testthat/test-location-path.R b/tests/testthat/test-location-path.R index a66e6e3e..a951dd6c 100644 --- a/tests/testthat/test-location-path.R +++ b/tests/testthat/test-location-path.R @@ -334,10 +334,11 @@ test_that("Can read metadata files with a trailing newline", { path <- file.path(root$path, ".outpack", "metadata", id) # Calling writeLines adds the trailing newline and mimicks the old orderly2 - # behaviour. + # behaviour. The size will be one or two bytes bigger than the actual data, + # depending on whether the newline is `\n` or `\r\n`. old_size <- file.info(path)$size writeLines(read_string(path), path) - expect_equal(file.info(path)$size, old_size + 1) + expect_gte(file.info(path)$size, old_size + 1) # Reading the metadata from a location at that path correctly strips the # newline and hashes correctly. diff --git a/tests/testthat/test-util.R b/tests/testthat/test-util.R index e2fb228d..bac860c5 100644 --- a/tests/testthat/test-util.R +++ b/tests/testthat/test-util.R @@ -328,7 +328,8 @@ test_that("read_string strips newlines", { writeLines(c("", "12345678"), path) # 8 characters, a leading newline and a trailing one - expect_equal(file.info(path)$size, 10) + # Each newline may be one of two bytes each, depending on the platform. + expect_gte(file.info(path)$size, 10) result <- expect_silent(read_string(path)) expect_equal(result, "12345678")