Skip to content

Commit

Permalink
Make pandoc-fail fail for modern pandoc (#2101)
Browse files Browse the repository at this point in the history
Fixes #2096
  • Loading branch information
hadley authored Jun 1, 2022
1 parent df9937f commit 35cb6e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
12 changes: 7 additions & 5 deletions tests/testthat/_snaps/rmarkdown.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# render_rmarkdown yields useful error

Code
render_rmarkdown(pkg, "assets/pandoc-fail.Rmd", "test.html")
render_rmarkdown(pkg, "assets/pandoc-fail.Rmd", "test.html", output_format = rmarkdown::html_document(
pandoc_args = "--fail-if-warnings"))
Output
Reading 'assets/pandoc-fail.Rmd'
-- RMarkdown error -------------------------------------------------------------
File path-to-image.png not found in resource path
Error : pandoc document conversion failed with error 99
[WARNING] Could not fetch resource path-to-image.png
Failing because there were warnings.
Error : pandoc document conversion failed with error 3
--------------------------------------------------------------------------------
Condition
Error in `render_rmarkdown()`:
! Failed to render RMarkdown
Caused by error:
! callr subprocess failed: pandoc document conversion failed with error 99
! callr subprocess failed: pandoc document conversion failed with error 3
Caused by error:
! pandoc document conversion failed with error 99
! pandoc document conversion failed with error 3

# render_rmarkdown styles ANSI escapes

Expand Down
7 changes: 4 additions & 3 deletions tests/testthat/test-rmarkdown.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ test_that("render_rmarkdown copies image files in subdirectories", {
})

test_that("render_rmarkdown yields useful error", {
skip_on_cran() # don't understand why it fails on CRAN
skip_if(rmarkdown::pandoc_version() >= "2.18")
skip_on_cran() # fragile due to pandoc dependency
skip_if_no_pandoc("2.18")

tmp <- dir_create(file_temp())
pkg <- list(src_path = test_path("."), dst_path = tmp, bs_version = 3)

expect_snapshot(error = TRUE, {
render_rmarkdown(pkg, "assets/pandoc-fail.Rmd", "test.html")
render_rmarkdown(pkg, "assets/pandoc-fail.Rmd", "test.html",
output_format = rmarkdown::html_document(pandoc_args = "--fail-if-warnings"))
})
})

Expand Down

0 comments on commit 35cb6e4

Please sign in to comment.