Skip to content

Commit

Permalink
Merge pull request #223 from kevinushey/bugfix/checking-tests-parsing
Browse files Browse the repository at this point in the history
allow for time durations in OK message
  • Loading branch information
gaborcsardi committed Aug 28, 2024
2 parents 17fa054 + ebc66eb commit e4e81db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

# rcmdcheck (development version)

* Fixed an issue where check output could be malformed when testing
packages with multiple test files (#205, @kevinushey).

* Update pkgdown template and move url to https://rcmdcheck.r-lib.org.

# rcmdcheck 1.4.0
Expand Down
11 changes: 9 additions & 2 deletions R/callback.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ 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 tests are run with `--as-cran`.
#
# https://github.com/r-lib/rcmdcheck/issues/205
ok_regex <- "^\\s+(\\[.*\\]\\s*)?OK"

no <- function(x, what = "") {
pattern <- paste0(" \\.\\.\\.[ ]?", what, "$")
sub("^\\*+ ", "", sub(pattern, "", x))
Expand Down Expand Up @@ -105,7 +112,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
Expand Down Expand Up @@ -163,7 +170,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_
Expand Down

0 comments on commit e4e81db

Please sign in to comment.