From fc79970f89b80f01a84069e0bbf57aee1ba5602d Mon Sep 17 00:00:00 2001 From: alexmcsw Date: Fri, 19 Sep 2025 12:23:49 -0400 Subject: [PATCH 1/4] Increment Roxygen version --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/package.R | 25 ++++++++++++++++++------- R/print.R | 10 ++++++++-- man/rcmdcheck.Rd | 1 - 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5165f1d..fc87c08 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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 diff --git a/NAMESPACE b/NAMESPACE index 329c61e..aac7a54 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/R/package.R b/R/package.R index 6a6c43e..8874751 100644 --- a/R/package.R +++ b/R/package.R @@ -3,7 +3,6 @@ #' Run R CMD check from R programmatically, and capture the results of the #' individual checks. #' -#' @docType package #' @name rcmdcheck NULL @@ -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()) @@ -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, @@ -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) @@ -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", @@ -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 diff --git a/R/print.R b/R/print.R index fe83acf..7dc85c4 100644 --- a/R/print.R +++ b/R/print.R @@ -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) { @@ -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]] diff --git a/man/rcmdcheck.Rd b/man/rcmdcheck.Rd index 0ecde39..6bf86bc 100644 --- a/man/rcmdcheck.Rd +++ b/man/rcmdcheck.Rd @@ -1,6 +1,5 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/package.R -\docType{package} \name{rcmdcheck} \alias{rcmdcheck} \title{Run R CMD check from R and Capture Results} From d350e3977cc5f75d095e437231ffade530e16007 Mon Sep 17 00:00:00 2001 From: alexmcsw Date: Fri, 19 Sep 2025 15:16:15 -0400 Subject: [PATCH 2/4] Change time theshold to 1s. Fixes #210 --- R/callback.R | 18 +++++++++++++----- R/options.R | 4 ++-- man/rcmdcheck-config.Rd | 4 ++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/R/callback.R b/R/callback.R index 79d0711..57ce308 100644 --- a/R/callback.R +++ b/R/callback.R @@ -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 @@ -68,9 +68,13 @@ block_callback <- function( prev_line <<- x ## NA_character_ can omit output - if (is.na(xx)) return() + if (is.na(xx)) { + return() + } - if (should_time) xx <- style(xx, timing = time_if_long()) + if (should_time) { + xx <- style(xx, timing = time_if_long()) + } line_started <<- now @@ -154,7 +158,9 @@ block_callback <- function( } ## Now focus on the current line, if we are still testing - if (state != "tests") return(NA_character_) + if (state != "tests") { + return(NA_character_) + } if (grepl("^\\s+Comparing.*OK$", x)) { ## Comparison, success style(ok = symbol$tick, pale = no(x, "OK")) @@ -218,7 +224,9 @@ block_callback <- function( } cat(" \r") lapply(lines, do_line) - if (state == "tests") do_test_partial_line(partial_line) + if (state == "tests") { + do_test_partial_line(partial_line) + } cat0(sub("^[\\* ]\\*?", " ", partial_line), "\r") } } diff --git a/R/options.R b/R/options.R index b6909c9..17613e3 100644 --- a/R/options.R +++ b/R/options.R @@ -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`, @@ -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: diff --git a/man/rcmdcheck-config.Rd b/man/rcmdcheck-config.Rd index cfd7818..b2a95a2 100644 --- a/man/rcmdcheck-config.Rd +++ b/man/rcmdcheck-config.Rd @@ -41,7 +41,7 @@ It not set, then the default of cli is uesed. The corresponding option is \code{rcmdcheck.num_colors}. \item \code{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 \code{rcmdcheck.timestamp_limit}. \item \code{RCMDCHECK_USE_RSTUDIO_PANDOC}: Flag (\code{true} or \code{false}). If \code{true}, then rcmdcheck \emph{always} puts RStudio's pandoc (if available) on the @@ -74,7 +74,7 @@ no test failures. If some tests fail, then only the failures are printed, independently of this option. \item \code{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 \code{RCMDCHECK_TIMESTAMP_LIMIT}. } } From ae99cae60e31eef6b7dc317598f8827c10993cc5 Mon Sep 17 00:00:00 2001 From: alexmcsw Date: Fri, 19 Sep 2025 15:16:43 -0400 Subject: [PATCH 3/4] Format tests. --- tests/testthat/test-callback.R | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/testthat/test-callback.R b/tests/testthat/test-callback.R index 344916a..633057d 100644 --- a/tests/testthat/test-callback.R +++ b/tests/testthat/test-callback.R @@ -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")) + } ) }) @@ -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) + } ) }) @@ -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) + } ) }) @@ -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")) + } ) }) @@ -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")) + } ) }) From bd8d7fc83747ad82faea0d400708a65dc7ae51ea Mon Sep 17 00:00:00 2001 From: alexmcsw Date: Fri, 19 Sep 2025 15:33:27 -0400 Subject: [PATCH 4/4] undo autoformatting --- R/callback.R | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/R/callback.R b/R/callback.R index 57ce308..f9b218a 100644 --- a/R/callback.R +++ b/R/callback.R @@ -68,13 +68,10 @@ block_callback <- function( prev_line <<- x ## NA_character_ can omit output - if (is.na(xx)) { - return() - } + if (is.na(xx)) return() + + if (should_time) xx <- style(xx, timing = time_if_long()) - if (should_time) { - xx <- style(xx, timing = time_if_long()) - } line_started <<- now @@ -158,9 +155,8 @@ block_callback <- function( } ## Now focus on the current line, if we are still testing - if (state != "tests") { - return(NA_character_) - } + if (state != "tests") return(NA_character_) + if (grepl("^\\s+Comparing.*OK$", x)) { ## Comparison, success style(ok = symbol$tick, pale = no(x, "OK")) @@ -224,9 +220,7 @@ block_callback <- function( } cat(" \r") lapply(lines, do_line) - if (state == "tests") { - do_test_partial_line(partial_line) - } + if (state == "tests") do_test_partial_line(partial_line) cat0(sub("^[\\* ]\\*?", " ", partial_line), "\r") } }