Skip to content

Commit cc625e3

Browse files
authored
Try even harder to suppress pak's output (#2681)
Somehow the nested use of callr (first layer is parallel testthat workers, second layer is inside pak) gives rise to some very difficult to suppress output. This is just about reducing noise in the testthat report.
1 parent 0c6c11c commit cc625e3

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

R/install.R

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,26 @@ install <- function(
8080
if (quiet) {
8181
withr::local_output_sink(withr::local_tempfile())
8282
withr::local_message_sink(withr::local_tempfile())
83+
# pak uses callr internally. When install() itself runs inside a callr
84+
# worker (e.g. testthat parallel tests), pak's callr_message conditions
85+
# leak to the parent process. Muffle them here; tryInvokeRestart() is a
86+
# safe no-op when the muffleMessage restart doesn't exist.
87+
withCallingHandlers(
88+
pak::local_install_deps(
89+
pkg$path,
90+
upgrade = upgrade,
91+
dependencies = dependencies || isTRUE(build_vignettes)
92+
),
93+
callr_message = function(cnd) tryInvokeRestart("muffleMessage")
94+
)
8395
} else {
8496
cli::cat_rule("pak::local_install_deps()", col = "cyan")
97+
pak::local_install_deps(
98+
pkg$path,
99+
upgrade = upgrade,
100+
dependencies = dependencies || isTRUE(build_vignettes)
101+
)
85102
}
86-
pak::local_install_deps(
87-
pkg$path,
88-
upgrade = upgrade,
89-
dependencies = dependencies || isTRUE(build_vignettes)
90-
)
91103
})
92104

93105
if (isTRUE(build_vignettes)) {

0 commit comments

Comments
 (0)