Skip to content

Commit 761dd68

Browse files
authored
disable lockfile generation in callr, testthat::tests and R CMD CHECK (#1346)
Part of #1263 and closes #1276 Local results of `shinytest2` tests ```r ══ Results ══════════════════════════════════════════════════════════════════════════ Duration: 540.8 s ── Skipped tests (6) ──────────────────────────────────────────────────────────────── • need a fix in a .slicesGlobal (1): test-module_teal.R:1139:11 • todo (5): test-module_teal.R:1404:7, test-module_teal.R:1411:5, test-module_teal.R:1414:5, test-module_teal.R:1673:5, test-module_teal.R:1731:5 [ FAIL 0 | WARN 0 | SKIP 6 | PASS 515 ] ```
1 parent 82bb3fb commit 761dd68

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

R/module_teal_lockfile.R

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ srv_teal_lockfile <- function(id) {
7474
})
7575

7676
lockfile_path <- "teal_app.lock"
77-
is_lockfile_enabled <- isTRUE(getOption("teal.lockfile.enable"))
77+
is_lockfile_enabled <- .is_lockfile_enabled()
7878
user_lockfile_path <- getOption("teal.lockfile.path", default = "")
7979
is_user_lockfile_set <- !identical(user_lockfile_path, "")
8080

@@ -194,3 +194,19 @@ utils::globalVariables(c("opts", "sysenv", "libpaths", "wd", "lockfilepath", "ru
194194
.is_lockfile_deps_installed <- function() {
195195
requireNamespace("mirai", quietly = TRUE) && requireNamespace("renv", quietly = TRUE)
196196
}
197+
198+
#' @rdname module_teal_lockfile
199+
.is_lockfile_enabled <- function() {
200+
if (isTRUE(getOption("teal.lockfile.enable"))) {
201+
return(TRUE)
202+
} else {
203+
!(
204+
identical(Sys.getenv("CALLR_IS_RUNNING"), "true") || # inside callr process
205+
identical(Sys.getenv("TESTTHAT"), "true") || # inside devtools::test
206+
!identical(Sys.getenv("QUARTO_PROJECT_ROOT"), "") || # inside Quarto process
207+
(
208+
("CheckExEnv" %in% search()) || any(c("_R_CHECK_TIMINGS_", "_R_CHECK_LICENSE_") %in% names(Sys.getenv()))
209+
) # inside R CMD CHECK
210+
)
211+
}
212+
}

R/zzz.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.onLoad <- function(libname, pkgname) {
22
# adapted from https://github.com/r-lib/devtools/blob/master/R/zzz.R
3+
34
teal_default_options <- list(
45
teal.show_js_log = FALSE,
5-
teal.lockfile.enable = TRUE,
66
shiny.sanitize.errors = FALSE
77
)
88

tests/testthat/setup-options.R

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
withr::local_options(
2-
# we should't run lockfile process multiple times in tests as it starts background process which is not
3-
# possible to kill once run. It means that background R sessions are being cumulated
4-
list(teal.lockfile.enable = FALSE),
5-
.local_envir = testthat::teardown_env()
6-
)
71

82
# `opts_partial_match_old` is left for exclusions due to partial matching in dependent packages (i.e. not fixable here)
93
# it might happen that it is not used right now, but it is left for possible future use

0 commit comments

Comments
 (0)