diff --git a/R/xlsx_cutter.R b/R/xlsx_cutter.R index 2b3a346..e2b596a 100644 --- a/R/xlsx_cutter.R +++ b/R/xlsx_cutter.R @@ -82,8 +82,9 @@ xlsx_cutter <- function( if (any(failed)) { warning( - "parsing failed for ", sum(failed), " files:\n", - toString(data_files[failed]) + "parsing failed for ", sum(failed), " files:\n - ", + paste(data_files[failed], collapse = "\n - "), + call. = FALSE ) } diff --git a/tests/testthat/_snaps/xlsx_cutter.md b/tests/testthat/_snaps/xlsx_cutter.md index a302d27..7c5aac1 100644 --- a/tests/testthat/_snaps/xlsx_cutter.md +++ b/tests/testthat/_snaps/xlsx_cutter.md @@ -63,3 +63,9 @@ ] } +# failures don't stop loop + + parsing failed for 2 files: + - nonexistent_file.xlsx + - nonexistent_file2.xlsx + diff --git a/tests/testthat/test-xlsx_cutter.R b/tests/testthat/test-xlsx_cutter.R index c4958b2..92bf330 100644 --- a/tests/testthat/test-xlsx_cutter.R +++ b/tests/testthat/test-xlsx_cutter.R @@ -19,3 +19,16 @@ test_that("xlsx_cutter() works", { ) }) + +test_that("failures don't stop loop", { + + expect_snapshot_warning( + res <- xlsx_cutter( # nolintr: assignment_linter. + c("nonexistent_file.xlsx", "nonexistent_file2.xlsx", data_files), + template_file + ) + ) + + expect_identical(nrow(res), length(data_files)) + +})