r-lib / rcmdcheck

Run R CMD check from R and collect the results
https://rcmdcheck.r-lib.org
Other
115 stars 27 forks source link

Test parsing is messed up in RStudio build pane #205

Closed hadley closed 2 months ago

hadley commented 1 year ago
Screenshot 2023-06-05 at 11 01 23

But it looks fine if I run rcmdcheck::rcmdcheck() in the console 😞

Screenshot 2023-06-05 at 11 04 04
stephenashton-dhsc commented 9 months ago

I was seeing something similar, but only when devtools::check() is invoked.

For example, if I call devtools::check() in the console, or if I run the check in the RStudio Build pane with Project Options > Build Tools > Use devtools package functions if available checked, then I get similar formatting issues:

image

Alternatively, if I call rcmdcheck::rcmdcheck() in the console, or I run the check in the RStudio Build pane with Project Options > Build Tools > Use devtools package functions if available unchecked, then the formatting is correct:

image

Looking a bit further, devtools::check() sets some of the arguments when calling rcmdcheck::rcmdcheck() - working from here, it appears as though the formatting issue is linked to the use of "--as-cran". For example, rcmdcheck::rcmdcheck(args="--as-cran") will have the formatting issues present.

Hope this digging helps work out what is causing the bug! :)

stephenashton-dhsc commented 9 months ago

Digging further again, it looks like it is to do with how the stdout is formatted during the call to callr::rcmd_safe().

If the cmdargs argument contains --as-cran, then the formatting bug appears in rcmdcheck(), independent of whether detect_callback() uses as_cran = TRUE or as_cran = FALSE.

Below are the raw test-related parts of stdout:

With --as-cran: * checking for unstated dependencies in 'tests' ... OK\r\n* checking tests ...\r\n Running 'spelling.R'\r\n Running 'testthat.R' [20s]\r\n [20s] OK\r\n* checking for unstated dependencies in vignettes ... OK\r\n

Without --as-cran: * checking for unstated dependencies in 'tests' ... OK\r\n* checking tests ...\r\n Running 'spelling.R'\r\n Running 'testthat.R'\r\n OK\r\n* checking for unstated dependencies in vignettes ... OK\r\n

I suspect it is the appearance of [20s] OK\r\n which is causing the issue - this is also present if R CMD check --as-cran is run in the terminal, so I suspect that block_callback() will need to be modified to handle this stdout return.

hadley commented 9 months ago

@stephenashton-dhsc thanks for digging into this!