Skip to content

Commit

Permalink
options for strict tests; few enhancements (#52)
Browse files Browse the repository at this point in the history
- part of
insightsengineering/coredev-tasks#478
- please read this for more info about the implementation:
insightsengineering/coredev-tasks#478 (comment)

---------

Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
  • Loading branch information
pawelru and dependabot-preview[bot] committed Mar 4, 2024
1 parent 12fa84c commit 8dab731
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Suggests:
knitr,
rmarkdown,
testthat (>= 3.1),
vdiffr
vdiffr,
withr (>= 2.0.0)
VignetteBuilder:
knitr
Config/testthat/edition: 3
Expand Down
20 changes: 20 additions & 0 deletions tests/testthat/setup-options.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# `opts_partial_match_old` is left for exclusions due to partial matching in dependent packages (i.e. not fixable here)
# it might happen that it is not used right now, but it is left for possible future use
# use with: `withr::with_options(opts_partial_match_old, { ... })` inside the test
opts_partial_match_old <- list(
warnPartialMatchDollar = getOption("warnPartialMatchDollar"),
warnPartialMatchArgs = getOption("warnPartialMatchArgs"),
warnPartialMatchAttr = getOption("warnPartialMatchAttr")
)
opts_partial_match_new <- list(
warnPartialMatchDollar = TRUE,
warnPartialMatchArgs = TRUE,
warnPartialMatchAttr = TRUE
)

if (isFALSE(getFromNamespace("on_cran", "testthat")()) && requireNamespace("withr", quietly = TRUE)) {
withr::local_options(
opts_partial_match_new,
.local_envir = testthat::teardown_env()
)
}

0 comments on commit 8dab731

Please sign in to comment.