Skip to content

Commit ba93a3c

Browse files
also catch warning; clean-up
1 parent e9d763c commit ba93a3c

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

inst/tests/tests.Rraw

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21194,14 +21194,14 @@ setDT(get0("dt_get0"))
2119421194
test(2319.2, !is.null(attr(dt_get0, ".internal.selfref")))
2119521195

2119621196
# Improved fread error handling for cmd exe and decompression #5415
21197-
test(2320.1, fread(cmd="false"), error="External command failed with exit code") # external command execution error handling
21198-
21199-
if (test_R.utils) {
21200-
tmp <- tempfile(fileext=".csv.gz")
21201-
file.create(tmp)
21202-
conn <- file(tmp, 'wb')
21203-
writeBin(as.raw(c(31, 139)), conn) # Gzip header starts with magic numbers: 0x1F 0x8B (decimal 31, 139) - these identify the file as gzip
21204-
close(conn)
21205-
test(2320.2, fread(tmp), warning="R.utils::decompressFile") # Compressed file decompression error handling - catches warning first
21206-
unlink(tmp)
21207-
}
21197+
test(2320.1, fread(cmd="false"), error="External command failed with exit code")
21198+
21199+
if (test_R.utils) local({
21200+
tmp <- tempfile(fileext=".gz")
21201+
file.create(tmp); on.exit(unlink(tmp))
21202+
local({
21203+
conn <- file(tmp, 'wb'); on.exit(close(conn))
21204+
writeBin(as.raw(c(31L, 139L)), conn) # Gzip header magic numbers to trigger that read path
21205+
})
21206+
test(2320.2, fread(tmp), error="R.utils::decompressFile failed to decompress", warning="invalid")
21207+
})

0 commit comments

Comments
 (0)