From 268df118bb397825cb0e7c9869b86df32f013c34 Mon Sep 17 00:00:00 2001 From: Salim B Date: Wed, 26 Feb 2025 16:11:54 +0100 Subject: [PATCH] test: fix `pandoc --fail-if-warnings` test for recent versions of Pandoc --- tests/testthat/_snaps/build-article.md | 16 ---------------- tests/testthat/test-build-article.R | 11 ++++++++--- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/tests/testthat/_snaps/build-article.md b/tests/testthat/_snaps/build-article.md index 802524b72..7eecda1d1 100644 --- a/tests/testthat/_snaps/build-article.md +++ b/tests/testthat/_snaps/build-article.md @@ -27,22 +27,6 @@ ## X -# build_article yields useful error if pandoc fails - - Code - build_article("test", pkg, pandoc_args = "--fail-if-warnings") - Message - Reading vignettes/test.Rmd - Condition - Error in `build_article()`: - ! Failed to render 'vignettes/test.Rmd'. - x [WARNING] This document format requires a nonempty element. - x Defaulting to 'test.knit' as the title. - x To specify a title, use 'title' in metadata or --metadata title="...". - x Failing because there were warnings. - Caused by error: - ! pandoc document conversion failed with error 3 - # build_article yields useful error if R fails Code diff --git a/tests/testthat/test-build-article.R b/tests/testthat/test-build-article.R index 5429d9251..5bd76034b 100644 --- a/tests/testthat/test-build-article.R +++ b/tests/testthat/test-build-article.R @@ -176,11 +176,16 @@ test_that("build_article yields useful error if pandoc fails", { skip_if_no_pandoc("2.18") pkg <- local_pkgdown_site() - pkg <- pkg_add_file(pkg, "vignettes/test.Rmd", "Hi") + pkg <- pkg_add_file(pkg, "vignettes/test.Rmd", c( + "Some text.", + "", + "[^1]: Unreferenced footnote.", + "" + )) - expect_snapshot( + expect_error( build_article("test", pkg, pandoc_args = "--fail-if-warnings"), - error = TRUE + "Note with key .+ defined at .+ but not used" ) })