From 327479791e47f11b34b2c4907b8f8dfba83ce2d8 Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Thu, 15 Aug 2024 14:56:48 -0700 Subject: [PATCH 1/4] allow for time durations in OK message --- NEWS.md | 3 +++ R/callback.R | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 48c9822..1fa7bba 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ # rcmdcheck (development version) +* Fixed an issue where check output could be malformed when testing + packages with multiple test files (#205). + * Update pkgdown template and move url to https://rcmdcheck.r-lib.org. # rcmdcheck 1.4.0 diff --git a/R/callback.R b/R/callback.R index 58fc283..9d4d17a 100644 --- a/R/callback.R +++ b/R/callback.R @@ -22,9 +22,17 @@ block_callback <- function( now <- NULL prev_line <- "" + # R may print a duration before emitting 'OK' when reporting + # elapsed time when running tests; the behavior seems to depend + # on whether test are run with `--as-cran`. + # + # https://github.com/r-lib/rcmdcheck/issues/205 + ok_regex <- "^\\s+(\\[.*\\]\\s*)?OK" + no <- function(x, what = "") { + what <- paste0("\\Q", what, "\\E") pattern <- paste0(" \\.\\.\\.[ ]?", what, "$") - sub("^\\*+ ", "", sub(pattern, "", x)) + sub("^\\*+ ", "", sub(pattern, "", x, perl = TRUE)) } time_if_long <- function() { @@ -105,7 +113,7 @@ block_callback <- function( do_test_mode <- function(x) { ## Maybe we just learned the result of the current test file if (test_running) { - if (grepl("^\\s+OK", x)) { + if (grepl(ok_regex, x)) { ## Tests are over, success state <<- "OK" test_running <<- FALSE @@ -163,7 +171,7 @@ block_callback <- function( now <<- sys_time() test_running <<- TRUE NA_character_ - } else if (grepl("^\\s+OK", x)) { + } else if (grepl(ok_regex, x)) { state <<- "OK" test_running <<- FALSE NA_character_ From 61012b399986e55a8636b4745debbf5cf3be729d Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Thu, 15 Aug 2024 15:22:36 -0700 Subject: [PATCH 2/4] remove unnecessary change --- R/callback.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/callback.R b/R/callback.R index 9d4d17a..204cc0e 100644 --- a/R/callback.R +++ b/R/callback.R @@ -30,9 +30,8 @@ block_callback <- function( ok_regex <- "^\\s+(\\[.*\\]\\s*)?OK" no <- function(x, what = "") { - what <- paste0("\\Q", what, "\\E") pattern <- paste0(" \\.\\.\\.[ ]?", what, "$") - sub("^\\*+ ", "", sub(pattern, "", x, perl = TRUE)) + sub("^\\*+ ", "", sub(pattern, "", x)) } time_if_long <- function() { From 3279464d08d387e527a427512a78ed4f2300711a Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Thu, 15 Aug 2024 15:23:11 -0700 Subject: [PATCH 3/4] fixup --- R/callback.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/callback.R b/R/callback.R index 204cc0e..51dbeb4 100644 --- a/R/callback.R +++ b/R/callback.R @@ -24,7 +24,7 @@ block_callback <- function( # R may print a duration before emitting 'OK' when reporting # elapsed time when running tests; the behavior seems to depend - # on whether test are run with `--as-cran`. + # on whether tests are run with `--as-cran`. # # https://github.com/r-lib/rcmdcheck/issues/205 ok_regex <- "^\\s+(\\[.*\\]\\s*)?OK" From ebc66eb6f24491344c7265ad6b5419baf288327c Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Thu, 15 Aug 2024 16:50:54 -0700 Subject: [PATCH 4/4] add author --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 1fa7bba..7535603 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,7 +2,7 @@ # rcmdcheck (development version) * Fixed an issue where check output could be malformed when testing - packages with multiple test files (#205). + packages with multiple test files (#205, @kevinushey). * Update pkgdown template and move url to https://rcmdcheck.r-lib.org.