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))) {
7
7
}
8
8
9
9
if (refers_to_file(x )) {
10
- x <- paste(readLines(x ), collapse = " \n " )
10
+ x <- paste(readLines(x , warn = FALSE ), collapse = " \n " )
11
11
} else if (length(x ) > 1L ) {
12
12
x <- paste(x , collapse = " \n " )
13
13
}
Original file line number Diff line number Diff line change @@ -66,3 +66,14 @@ test_that("can check if path includes dir", {
66
66
expect_false(path_includes_dir(" file.json" ))
67
67
expect_true(path_includes_dir(" the/file.json" ))
68
68
})
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