tests/testthat/test-compiler-flags.R

test_that("has_compiler_colored_diagnostics", {
  local_mocked_bindings(cache_exists = function(...) stop("nope"))

  withr::local_envvar(PKG_BUILD_COLOR_DIAGNOSTICS = "true")
  expect_true(has_compiler_colored_diagnostics())

  withr::local_envvar(PKG_BUILD_COLOR_DIAGNOSTICS = "false")
  expect_false(has_compiler_colored_diagnostics())

  withr::local_envvar(PKG_BUILD_COLOR_DIAGNOSTICS = NA_character_)
  expect_error(has_compiler_colored_diagnostics(), "nope")
})

Try the pkgbuild package in your browser

Any scripts or data that you put into this service are public.

pkgbuild documentation built on Oct. 30, 2024, 9:08 a.m.