File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ get_string <- function(x, what = deparse(substitute(x))) {
77 }
88
99 if (refers_to_file(x )) {
10- x <- paste(readLines(x ), collapse = " \n " )
10+ x <- paste(readLines(x , warn = FALSE ), collapse = " \n " )
1111 } else if (length(x ) > 1L ) {
1212 x <- paste(x , collapse = " \n " )
1313 }
Original file line number Diff line number Diff line change @@ -66,3 +66,14 @@ test_that("can check if path includes dir", {
6666 expect_false(path_includes_dir(" file.json" ))
6767 expect_true(path_includes_dir(" the/file.json" ))
6868})
69+
70+ test_that(" can read file with no trailing newline" , {
71+ path <- tempfile()
72+ writeLines(" 12345678" , path , sep = " " )
73+
74+ # Check that we wrote just what we wanted and no more.
75+ expect_equal(file.info(path )$ size , 8 )
76+
77+ result <- expect_silent(get_string(path ))
78+ expect_equal(result , " 12345678" )
79+ })
You can’t perform that action at this time.
0 commit comments