Skip to contents

Isolated behind its own function – rather than calling processx::process$new() directly inside deck_serve() – specifically so it's mockable: testthat::local_mocked_bindings() can only replace a binding that already exists as a named object in a namespace/frame, and process$new is an R6 generator method, not a plain function binding, so it can't be intercepted that way (confirmed directly: mocking new via .package = "processx" errors with "Can't find binding for new", since processx's own namespace never binds a bare new symbol). This function is the one line that actually calls it, so tests fake this function instead via local_mocked_bindings(.launch_server_process = ..., .env = environment()) – the same "wrap the unmockable call in a small internal function" seam this file's own .wait_for_server() uses for socketConnection(), just applied to an R6 method instead of a base function.

Usage

.launch_server_process(uv_path, args, env_vars)

Arguments

uv_path

Path to the uv binary, from pyro::get_venv_uv_paths().

args

CLI arguments to pass to uv (c("run", "-m", "deckifyr", "serve", ...)).

env_vars

Environment for the subprocess, in processx's own c("current", NAME = value, ...) form.

Value

A processx::process object, not yet awaited.

Details

Its own body is marked # nocov for the same reason it exists at all: every unit test replaces this whole function (there's nothing finer to mock, unlike e.g. .run_deckifyr_cli()'s own call to pyro::run_python_script() – an ordinary function, directly mockable at the call site, so .run_deckifyr_cli()'s own body stays covered by its mocked-pyro unit tests). The real processx::process$new() call here only executes for real inside tests/testthat/test-wiring.R's gated end-to-end block, which needs a real .venv/uv/pyro install and correctly skips without one – including in test-coverage.yaml's own CI job, per this repo's already-established "an honest, accepted coverage gap, not a problem to hide" precedent (CLAUDE.md).