diff --git a/R/utils.R b/R/utils.R index f5e4b49..a6416e6 100644 --- a/R/utils.R +++ b/R/utils.R @@ -191,11 +191,11 @@ get_desc_config_flag <- function(path, name) { return(FALSE) } - stop(cli::format_error( + stop(cli::format_error(c( "The {.code {name}} entry in {.path DESCRIPTION} must be {.code TRUE} or {.code FALSE}.", - "i" = "It is {.val {val}}." - )) + i = "It is {.val {val}}." + ))) } mkdirp <- function(path, mode = NULL) { diff --git a/tests/testthat/_snaps/utils.md b/tests/testthat/_snaps/utils.md index 1bbab1a..efab4c3 100644 --- a/tests/testthat/_snaps/utils.md +++ b/tests/testthat/_snaps/utils.md @@ -41,3 +41,12 @@ ! Invalid `PKG_BUILD_EXTRA_FLAGS` environment variable. i Must be one of `true`, `false` or `missing`. +# get_desc_config_flag errors on invalid DESCRIPTION value + + Code + get_desc_config_flag(path, "never-clean") + Condition + Error in `get_desc_config_flag()`: + ! The `Config/build/never-clean` entry in 'DESCRIPTION' must be `TRUE` or `FALSE`. + i It is "maybe". + diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 66550af..5b35099 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -94,3 +94,14 @@ test_that("should_add_compiler_flags errors", { withr::local_envvar(PKG_BUILD_EXTRA_FLAGS = "foo") expect_snapshot(error = TRUE, should_add_compiler_flags()) }) + +test_that("get_desc_config_flag errors on invalid DESCRIPTION value", { + path <- withr::local_tempfile( + lines = c( + "Package: test", + "Version: 1.0", + "Config/build/never-clean: maybe" + ) + ) + expect_snapshot(error = TRUE, get_desc_config_flag(path, "never-clean")) +})