From bcc2f6148b667d2551908d825542286c34cd0138 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Thu, 24 Oct 2019 10:26:41 +0200 Subject: [PATCH] always use encoding with readLines() --- tests/testthat/test_a_basics.R | 4 ++-- tests/testthat/test_b_is_git2rmeta.R | 2 +- tests/testthat/test_e_validate_metadata.R | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test_a_basics.R b/tests/testthat/test_a_basics.R index cba36f3..516b68a 100644 --- a/tests/testthat/test_a_basics.R +++ b/tests/testthat/test_a_basics.R @@ -255,7 +255,7 @@ test_that("user specified na strings work", { ) git2rdata:::set_local_locale(old_locale) expect_identical( - grep("junk", readLines(file.path(root, fn[1]))), + grep("junk", readLines(file.path(root, fn[1]), encoding = "UTF-8")), 2:4 ) expect_error( @@ -279,7 +279,7 @@ test_that("user specified na strings work", { ) git2rdata:::set_local_locale(old_locale) expect_identical( - grep("junk", readLines(file.path(root, fn[1]))), + grep("junk", readLines(file.path(root, fn[1]), encoding = "UTF-8")), 2:4 ) file.remove(list.files(root, recursive = TRUE, full.names = TRUE)) diff --git a/tests/testthat/test_b_is_git2rmeta.R b/tests/testthat/test_b_is_git2rmeta.R index 15d1c69..88186f7 100644 --- a/tests/testthat/test_b_is_git2rmeta.R +++ b/tests/testthat/test_b_is_git2rmeta.R @@ -122,7 +122,7 @@ test_that("is_git2rdata checks data", { junk <- write_vc(test_data, file = file, root = root, sorting = "test_Date") correct_yaml <- yaml::read_yaml(file.path(root, junk[2])) yaml::write_yaml(correct_yaml, file.path(root, junk[2])) - correct_data <- readLines(file.path(root, junk[1])) + correct_data <- readLines(file.path(root, junk[1]), encoding = "UTF-8") junk_header <- correct_data junk_header[1] <- "junk" writeLines(junk_header, file.path(root, junk[1])) diff --git a/tests/testthat/test_e_validate_metadata.R b/tests/testthat/test_e_validate_metadata.R index c7017d7..748f702 100644 --- a/tests/testthat/test_e_validate_metadata.R +++ b/tests/testthat/test_e_validate_metadata.R @@ -35,7 +35,7 @@ test_that("read_vc() checks hash", { test_that("read_vc() handles changes in rawdata", { file <- basename(tempfile(tmpdir = root)) junk <- write_vc(test_data, file = file, root = root, sorting = "test_Date") - correct_data <- readLines(file.path(root, junk[1])) + correct_data <- readLines(file.path(root, junk[1]), encoding = "UTF-8") correct_header <- strsplit(correct_data[1], "\t")[[1]] junk_data <- correct_data junk_data[1] <- paste(correct_header[-1], collapse = "\t")