Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions tests/testthat/_snaps/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -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".

11 changes: 11 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
})
Loading