Skip to content

Commit 28b24db

Browse files
FIX: Failed to detect 'R CMD check' on win-builder causing examples to run with default progressr.demo.delay=1.0 (seconds)
1 parent 1c367d7 commit 28b24db

File tree

5 files changed

+21
-17
lines changed

5 files changed

+21
-17
lines changed

R/handlers.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ handlers <- function(..., append = FALSE, on_missing = c("error", "warning", "ig
3232

3333
## Get the current set of progression handlers?
3434
if (length(args) == 0L) {
35-
if (!is.list(default)) default <- list(default)
35+
if (!is.list(default) && !is.null(default)) default <- list(default)
3636
return(getOption("progressr.handlers", default))
3737
}
3838

R/utils.R

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ query_r_cmd_check <- function(...) {
120120

121121
# Command line arguments
122122
args <- commandArgs()
123+
123124
evidences[["vanilla"]] <- is.element("--vanilla", args)
124125

125126
# Check the working directory
@@ -130,15 +131,28 @@ query_r_cmd_check <- function(...) {
130131

131132
# Is 'R CMD check' checking tests?
132133
evidences[["tests"]] <- (
133-
(regexpr(pattern, parent) != -1) &&
134-
(regexpr("^tests(|_.*)$", dirname) != -1)
134+
grepl(pattern, parent) && grepl("^tests(|_.*)$", dirname)
135135
)
136136

137137
# Is the current working directory as expected?
138-
evidences[["pwd"]] <- (evidences[["tests"]] || (regexpr(pattern, dirname) != -1))
138+
evidences[["pwd"]] <- (evidences[["tests"]] || grepl(pattern, dirname))
139139

140140
# Is 'R CMD check' checking examples?
141141
evidences[["examples"]] <- is.element("CheckExEnv", search())
142+
143+
# SPECIAL: win-builder?
144+
evidences[["win-builder"]] <- (.Platform$OS.type == "windows" && grepl("Rterm[.]exe$", args[1]))
145+
146+
if (evidences[["win-builder"]]) {
147+
n <- length(args)
148+
if (all(c("--no-save", "--no-restore", "--no-site-file", "--no-init-file") %in% args)) {
149+
evidences[["vanilla"]] <- TRUE
150+
}
151+
152+
if (grepl(pattern, parent)) {
153+
evidences[["pwd"]] <- TRUE
154+
}
155+
}
142156

143157

144158
if (!evidences$vanilla || !evidences$pwd) {
@@ -151,6 +165,8 @@ query_r_cmd_check <- function(...) {
151165
res <- "notRunning"
152166
}
153167

168+
attr(res, "evidences") <- evidences
169+
154170
res
155171
}
156172

R/zzz.R

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
.onLoad <- function(libname, pkgname) {
22
if (in_r_cmd_check()) {
3-
msg <- sprintf("%s:::.onLoad(): Detected 'R CMD check'", pkgname)
4-
packageStartupMessage(msg)
53
options(progressr.demo.delay = 0.0)
64
}
7-
}
5+
}

incl/debug_handler.R

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
res <- progressr:::query_r_cmd_check()
2-
print(res)
3-
str(res)
4-
print(getOption("progressr.demo.delay", NA_real_))
5-
61
handlers("debug")
72
with_progress({ y <- slow_sum(1:10) })
83
print(y)

man/debug_handler.Rd

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)