Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ Config/testthat/edition: 3
Config/usethis/last-upkeep: 2025-05-07
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
RoxygenNote: 7.3.3
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ S3method(as.data.frame,rcmdcheck)
S3method(print,rcmdcheck)
S3method(print,rcmdcheck_comparison)
S3method(print,rcmdcheck_comparison_summary)
S3method(print,rcmdcheck_summary)
S3method(summary,rcmdcheck)
S3method(summary,rcmdcheck_comparison)
S3method(xopen,rcmdcheck)
Expand Down
4 changes: 3 additions & 1 deletion R/callback.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ block_callback <- function(
time_if_long <- function() {
limit <- as.numeric(getOption(
"rcmdcheck.timestamp_limit",
Sys.getenv("RCMDCHECK_TIMESTAMP_LIMIT", "0.33333")
Sys.getenv("RCMDCHECK_TIMESTAMP_LIMIT", "1")
))
elapsed <- now - line_started
line_started <<- now
Expand Down Expand Up @@ -72,6 +72,7 @@ block_callback <- function(

if (should_time) xx <- style(xx, timing = time_if_long())


line_started <<- now

cat(xx, "\n", sep = "")
Expand Down Expand Up @@ -155,6 +156,7 @@ block_callback <- function(

## Now focus on the current line, if we are still testing
if (state != "tests") return(NA_character_)

if (grepl("^\\s+Comparing.*OK$", x)) {
## Comparison, success
style(ok = symbol$tick, pale = no(x, "OK"))
Expand Down
4 changes: 2 additions & 2 deletions R/options.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#'
#' * `RCMDCHECK_TIMESTAMP_LIMIT`: lower limit is seconds, above which
#' rcmdcheck adds time stamps to the individual check steps. It may be
#' fractional. Defaults to 1/3 of a second. The corresponding option is
#' fractional. Defaults to 1 second. The corresponding option is
#' `rcmdcheck.timestamp_limit`.
#'
#' * `RCMDCHECK_USE_RSTUDIO_PANDOC`: Flag (`true` or `false`). If `true`,
Expand Down Expand Up @@ -78,7 +78,7 @@
#'
#' * `rcmdcheck.timestamp_limit`: lower limit is seconds, above which
#' rcmdcheck adds time stamps to the individual check steps. It may be
#' fractional. Defaults to 1/3 of a second. The corresponding environment
#' fractional. Defaults to 1 second. The corresponding environment
#' variable is `RCMDCHECK_TIMESTAMP_LIMIT`.
#'
#' # Package configuration:
Expand Down
25 changes: 18 additions & 7 deletions R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#' Run R CMD check from R programmatically, and capture the results of the
#' individual checks.
#'
#' @docType package
#' @name rcmdcheck
NULL

Expand Down Expand Up @@ -143,7 +142,9 @@ rcmdcheck <- function(
}

# Add pandoc to the PATH, for R CMD build and R CMD check
if (should_use_rs_pandoc()) local_path(Sys.getenv("RSTUDIO_PANDOC"))
if (should_use_rs_pandoc()) {
local_path(Sys.getenv("RSTUDIO_PANDOC"))
}

pkgbuild::without_cache(pkgbuild::local_build_tools())

Expand Down Expand Up @@ -175,7 +176,9 @@ rcmdcheck <- function(

on.exit(unlink(out$session_info, recursive = TRUE), add = TRUE)

if (isTRUE(out$timeout)) message("R CMD check timed out")
if (isTRUE(out$timeout)) {
message("R CMD check timed out")
}

res <- new_rcmdcheck(
stdout = out$result$stdout,
Expand All @@ -188,7 +191,9 @@ rcmdcheck <- function(
)

# Automatically delete temporary files when this object disappears
if (cleanup) res$cleaner <- auto_clean(check_dir)
if (cleanup) {
res$cleaner <- auto_clean(check_dir)
}

handle_error_on(res, error_on)

Expand Down Expand Up @@ -227,9 +232,13 @@ do_check <- function(
}

# user supplied env vars take precedence
if (length(env)) chkenv[names(env)] <- env
if (length(env)) {
chkenv[names(env)] <- env
}

if (!quiet) cat_head("R CMD check")
if (!quiet) {
cat_head("R CMD check")
}
callback <- if (!quiet) detect_callback(as_cran = "--as-cran" %in% args)
res <- rcmd_safe(
"check",
Expand All @@ -246,7 +255,9 @@ do_check <- function(
)

# To print an incomplete line on timeout or crash
if (!is.null(callback) && (res$timeout || res$status != 0)) callback("\n")
if (!is.null(callback) && (res$timeout || res$status != 0)) {
callback("\n")
}

# Non-zero status is an error, the check process failed
# R CMD check returns 1 for installation errors, we don't want to error
Expand Down
10 changes: 8 additions & 2 deletions R/print.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ header_line <- function(left = "", right = "", width = cli::console_width()) {
ncl <- nchar(left)
ncr <- nchar(right)

if (ncl) left <- paste0(" ", left, " ")
if (ncr) right <- paste0(" ", right, " ")
if (ncl) {
left <- paste0(" ", left, " ")
}
if (ncr) {
right <- paste0(" ", right, " ")
}
ndashes <- width - ((ncl > 0) * 2 + (ncr > 0) * 2 + ncl + ncr)

if (ndashes < 4) {
Expand Down Expand Up @@ -124,6 +128,8 @@ summary.rcmdcheck <- function(object, ...) {
structure(list(object), class = "rcmdcheck_summary")
}

#' @export

print.rcmdcheck_summary <- function(x, ..., line = TRUE) {
object <- x[[1]]

Expand Down
4 changes: 2 additions & 2 deletions man/rcmdcheck-config.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/rcmdcheck.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions tests/testthat/test-callback.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ test_that("block_callback by line", {
chk <- readLines(test_path("fixtures", "test-error.txt"))
cb <- block_callback()
expect_snapshot(
for (line in chk) cb(paste0(line, "\n"))
for (line in chk) {
cb(paste0(line, "\n"))
}
)
})

Expand Down Expand Up @@ -43,7 +45,9 @@ test_that("block_callback by chunks", {

cb <- block_callback()
expect_snapshot(
for (ch in chunks) cb(ch)
for (ch in chunks) {
cb(ch)
}
)
})

Expand All @@ -66,7 +70,9 @@ test_that("notes, errors, warnings", {
"* Step three ... ERROR\n More error text.\n"
)
expect_snapshot(
for (line in out) cb(line)
for (line in out) {
cb(line)
}
)
})

Expand Down Expand Up @@ -94,7 +100,9 @@ test_that("tests", {

cb <- block_callback()
expect_snapshot(
for (line in txt) cb(paste0(line, "\n"))
for (line in txt) {
cb(paste0(line, "\n"))
}
)
})

Expand All @@ -118,7 +126,9 @@ test_that("multi-arch tests", {

cb <- block_callback()
expect_snapshot(
for (line in txt) cb(paste0(line, "\n"))
for (line in txt) {
cb(paste0(line, "\n"))
}
)
})

Expand Down
Loading