From dfed20deafb187405a9591ea66d03adc0269ca14 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Tue, 21 May 2024 14:49:23 -0500 Subject: [PATCH] Use inline test --- tests/testthat/_snaps/package.md | 4 ++-- tests/testthat/assets/bad-yaml/DESCRIPTION | 3 --- tests/testthat/assets/bad-yaml/_pkgdown.yml | 6 ------ tests/testthat/test-package.R | 8 +++++++- 4 files changed, 9 insertions(+), 12 deletions(-) delete mode 100644 tests/testthat/assets/bad-yaml/DESCRIPTION delete mode 100644 tests/testthat/assets/bad-yaml/_pkgdown.yml diff --git a/tests/testthat/_snaps/package.md b/tests/testthat/_snaps/package.md index 3f6976305..08b1e5e6f 100644 --- a/tests/testthat/_snaps/package.md +++ b/tests/testthat/_snaps/package.md @@ -23,10 +23,10 @@ # read_meta() errors gracefully if _pkgdown.yml failed to parse Code - as_pkgdown(test_path("assets/bad-yaml")) + as_pkgdown(pkg$src_path) Condition Error in `as_pkgdown()`: - ! Could not parse config file at 'assets/bad-yaml/_pkgdown.yml'. + ! Could not parse config file at '/_pkgdown.yml'. Caused by error in `yaml.load()`: ! Scanner error: mapping values are not allowed in this context at line 2, column 8 diff --git a/tests/testthat/assets/bad-yaml/DESCRIPTION b/tests/testthat/assets/bad-yaml/DESCRIPTION deleted file mode 100644 index 2329d143b..000000000 --- a/tests/testthat/assets/bad-yaml/DESCRIPTION +++ /dev/null @@ -1,3 +0,0 @@ -Package: kittens -Authors@R: person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), -VignetteBuilder: knitr diff --git a/tests/testthat/assets/bad-yaml/_pkgdown.yml b/tests/testthat/assets/bad-yaml/_pkgdown.yml deleted file mode 100644 index 01904824d..000000000 --- a/tests/testthat/assets/bad-yaml/_pkgdown.yml +++ /dev/null @@ -1,6 +0,0 @@ -url: https://pkgdown.r-lib.org - title: Build websites for R packages - -authors: - Jay Hesselberth: - href: https://hesselberthlab.org diff --git a/tests/testthat/test-package.R b/tests/testthat/test-package.R index ffd061f51..a016207a9 100644 --- a/tests/testthat/test-package.R +++ b/tests/testthat/test-package.R @@ -84,8 +84,14 @@ test_that("titles don't get autolinked code", { }) test_that("read_meta() errors gracefully if _pkgdown.yml failed to parse", { + pkg <- local_pkgdown_site() + write_lines(path = path(pkg$src_path, "_pkgdown.yml"), c( + "url: https://pkgdown.r-lib.org", + " title: Build websites for R packages" + )) expect_snapshot( + as_pkgdown(pkg$src_path), error = TRUE, - as_pkgdown(test_path("assets/bad-yaml")) + transform = function(x) gsub(pkg$src_path, "", x, fixed = TRUE) ) })