diff --git a/R/package.R b/R/package.R index 6747f92f7..821144c8c 100644 --- a/R/package.R +++ b/R/package.R @@ -178,13 +178,8 @@ pkgdown_config_path <- function(path) { ) } -read_meta <- function(path, check_path = TRUE, call = caller_env()) { - if (check_path) { - # check_path = FALSE can be used to supply a direct path to - # read_meta instead of a pkgdown object. - path <- pkgdown_config_path(path) - } - +read_meta <- function(path, call = caller_env()) { + path <- pkgdown_config_path(path) if (is.null(path)) { yaml <- list() } else { diff --git a/tests/testthat/_snaps/package.md b/tests/testthat/_snaps/package.md index 01fdc3913..7482d9d7a 100644 --- a/tests/testthat/_snaps/package.md +++ b/tests/testthat/_snaps/package.md @@ -23,9 +23,9 @@ # read_meta() errors gracefully if _pkgdown.yml failed to parse Code - read_meta(file, check_path = FALSE) + as_pkgdown(test_path("assets/bad-yaml")) Condition - Error: + Error in `as_pkgdown()`: x Could not parse the config file. ! Parser error: while parsing a block mapping at line 1, column 1 did not find expected key at line 9, column 3 i Edit 'assets/bad-yaml/_pkgdown.yml' to fix the problem. diff --git a/tests/testthat/assets/bad-yaml/DESCRIPTION b/tests/testthat/assets/bad-yaml/DESCRIPTION new file mode 100644 index 000000000..3da3a37bf --- /dev/null +++ b/tests/testthat/assets/bad-yaml/DESCRIPTION @@ -0,0 +1,13 @@ +Package: kittens +Version: 1.0.0 +Title: A test package +Description: A longer statement about the package. +Authors@R: c( + person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), + person("RStudio", role = c("cph", "fnd")) + ) +RoxygenNote: 6.0.1 +Suggests: + knitr, + rmarkdown +VignetteBuilder: knitr diff --git a/tests/testthat/test-package.R b/tests/testthat/test-package.R index ca56ca769..ffd061f51 100644 --- a/tests/testthat/test-package.R +++ b/tests/testthat/test-package.R @@ -84,12 +84,8 @@ test_that("titles don't get autolinked code", { }) test_that("read_meta() errors gracefully if _pkgdown.yml failed to parse", { - file <- test_path("assets", "bad-yaml", "_pkgdown.yml") expect_snapshot( error = TRUE, - read_meta( - file, - check_path = FALSE - ) + as_pkgdown(test_path("assets/bad-yaml")) ) })