From de49478d136d87ab56c4777ffaa1aefe56d8dc02 Mon Sep 17 00:00:00 2001 From: Maximilian Scholz Date: Tue, 8 Sep 2026 22:14:38 +0200 Subject: [PATCH 1/2] Fix cli::format_error call in get_desc_config_flag --- R/utils.R | 6 +++--- tests/testthat/_snaps/utils.md | 9 +++++++++ tests/testthat/test-utils.R | 9 +++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) 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..7052fb4 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -94,3 +94,12 @@ 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")) +}) From bd7b28ed4ea0c8b5bd8c0b12daf9f05c870ef4af Mon Sep 17 00:00:00 2001 From: Maximilian Scholz Date: Wed, 9 Sep 2026 11:17:11 +0200 Subject: [PATCH 2/2] Air format new get_desc_config_flag test --- tests/testthat/test-utils.R | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 7052fb4..5b35099 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -96,10 +96,12 @@ test_that("should_add_compiler_flags errors", { }) 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" - )) + 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")) })