Skip to content

Commit 2cfd64d

Browse files
committed
Fix R CMD config capture
1 parent 4d9af22 commit 2cfd64d

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

R/aaa-utils.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ quickr_r_cmd_config_value <- function(
2828
r_cmd,
2929
c("CMD", "config", name),
3030
stdout = TRUE,
31-
stderr = TRUE
31+
stderr = FALSE
3232
)),
3333
error = function(e) character()
3434
)

tests/testthat/test-compiler.R

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,48 @@ test_that("quickr_env_is_true recognizes common truthy values", {
1111
expect_true(quickr:::quickr_env_is_true("QUICKR_PREFER_FLANG"))
1212
})
1313

14+
test_that("quickr_r_cmd_config_value captures only stdout", {
15+
observed_stdout <- NULL
16+
observed_stderr <- NULL
17+
system2_stub <- function(
18+
command,
19+
args,
20+
stdout = "",
21+
stderr = "",
22+
...
23+
) {
24+
observed_stdout <<- stdout
25+
observed_stderr <<- stderr
26+
" value "
27+
}
28+
29+
expect_identical(
30+
quickr:::quickr_r_cmd_config_value(
31+
"CC",
32+
r_cmd = "R",
33+
system2 = system2_stub
34+
),
35+
"value"
36+
)
37+
expect_identical(observed_stdout, TRUE)
38+
expect_identical(observed_stderr, FALSE)
39+
})
40+
41+
test_that("quickr_r_cmd_config_value returns empty on command failure", {
42+
system2_stub <- function(command, args, stdout = "", stderr = "", ...) {
43+
structure(" value ", status = 1L)
44+
}
45+
46+
expect_identical(
47+
quickr:::quickr_r_cmd_config_value(
48+
"CC",
49+
r_cmd = "R",
50+
system2 = system2_stub
51+
),
52+
""
53+
)
54+
})
55+
1456
test_that("quickr_flang_path and quickr_prefer_flang are deterministic with stubs", {
1557
which <- function(x) {
1658
if (x == "flang-new") {

0 commit comments

Comments
 (0)