Skip to content

Commit 1a01e1a

Browse files
committed
✨ Forward stdout/stderr from parallel tests ✨
I guess the question here is do we want to forward as we update the number of tests, or only at the end when we report the test failures etc. I can see arguments for either Fixes #2095
1 parent f56ecfd commit 1a01e1a

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

.claude/settings.local.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
2+
"$schema": "https://json.schemastore.org/claude-code-settings.json",
23
"permissions": {
34
"allow": [
45
"Bash(find:*)",
5-
"Bash(R:*)"
6+
"Bash(R:*)",
7+
"Bash(air format:*)"
68
],
79
"deny": []
8-
},
9-
"$schema": "https://json.schemastore.org/claude-code-settings.json"
10+
}
1011
}

R/parallel-taskq.R

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,25 @@ task_q <- R6::R6Class(
7070
pr <- processx::poll(conns, as_ms(timeout))
7171
ready <- topoll[pr == "ready"]
7272
results <- lapply(ready, function(i) {
73-
msg <- private$tasks$worker[[i]]$read()
73+
worker <- private$tasks$worker[[i]]
74+
msg <- worker$read()
75+
76+
# Also read any available stdout/stderr
77+
stdout_lines <- worker$read_output_lines()
78+
stderr_lines <- worker$read_error_lines()
79+
80+
# Forward stdout/stderr to console
81+
if (length(stdout_lines) > 0) {
82+
for (line in stdout_lines) {
83+
cat(line, "\n", file = stdout())
84+
}
85+
}
86+
if (length(stderr_lines) > 0) {
87+
for (line in stderr_lines) {
88+
cat(line, "\n", file = stderr())
89+
}
90+
}
91+
7492
## TODO: why can this be NULL?
7593
if (is.null(msg) || msg$code == PROCESS_MSG) {
7694
private$tasks$state[[i]] <- "running"
@@ -131,7 +149,7 @@ task_q <- R6::R6Class(
131149
args = nl,
132150
worker = nl
133151
)
134-
rsopts <- callr::r_session_options(...)
152+
rsopts <- callr::r_session_options(stdout = "|", stderr = "|", ...)
135153
for (i in seq_len(concurrency)) {
136154
rs <- callr::r_session$new(rsopts, wait = FALSE)
137155
private$tasks$worker[[i]] <- rs

tests/testthat/test-reporter-silent.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
cat("\nHello?\n")
2+
13
test_that("captures expectations; doesn't produce any output", {
24
reporter <- SilentReporter$new()
35
expect_snapshot_reporter(reporter)

0 commit comments

Comments
 (0)