Skip to content

Commit 4834f4e

Browse files
committed
turnoff renv in tests
1 parent 5fab6ce commit 4834f4e

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

R/zzz.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# adapted from https://github.com/r-lib/devtools/blob/master/R/zzz.R
33
teal_default_options <- list(
44
teal.show_js_log = FALSE,
5+
# todo: make below teal.renv.enable = FALSE during run_examples, test_package, r cmd check
6+
# run_examples probably doesn't set any sysvars but maybe detecting run_examples in sys.calls() helps
57
teal.renv.enable = TRUE,
68
shiny.sanitize.errors = FALSE
79
)

tests/testthat/setup-options.R

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
1+
# we should't run lockfile process multiple times in tests as it starts background process which is not
2+
# possible to kill once run. It means that background R sessions are being cumulated
13
withr::local_options(
2-
list(
3-
warnPartialMatchDollar = TRUE,
4-
warnPartialMatchArgs = TRUE,
5-
warnPartialMatchAttr = TRUE,
6-
teal.renv.enable = FALSE
7-
),
4+
list(teal.renv.enable = FALSE),
85
.local_envir = testthat::teardown_env()
96
)
7+
8+
# `opts_partial_match_old` is left for exclusions due to partial matching in dependent packages (i.e. not fixable here)
9+
# it might happen that it is not used right now, but it is left for possible future use
10+
# use with: `withr::with_options(opts_partial_match_old, { ... })` inside the test
11+
opts_partial_match_old <- list(
12+
warnPartialMatchDollar = getOption("warnPartialMatchDollar"),
13+
warnPartialMatchArgs = getOption("warnPartialMatchArgs"),
14+
warnPartialMatchAttr = getOption("warnPartialMatchAttr")
15+
)
16+
opts_partial_match_new <- list(
17+
warnPartialMatchDollar = TRUE,
18+
warnPartialMatchArgs = TRUE,
19+
warnPartialMatchAttr = TRUE
20+
)
21+
22+
if (isFALSE(getFromNamespace("on_cran", "testthat")()) && requireNamespace("withr", quietly = TRUE)) {
23+
withr::local_options(
24+
opts_partial_match_new,
25+
.local_envir = testthat::teardown_env()
26+
)
27+
}

0 commit comments

Comments
 (0)