1+ # # From R.utils 2.7.0 (2018-08-26)
2+ queryRCmdCheck <- function (... ) {
3+ evidences <- list ()
4+
5+ # Command line arguments
6+ args <- commandArgs()
7+
8+ evidences [[" vanilla" ]] <- is.element(" --vanilla" , args )
9+
10+ # Check the working directory
11+ pwd <- getwd()
12+ dirname <- basename(pwd )
13+ parent <- basename(dirname(pwd ))
14+ pattern <- " .+[.]Rcheck$"
15+
16+ # Is 'R CMD check' checking tests?
17+ evidences [[" tests" ]] <- (
18+ grepl(pattern , parent ) && grepl(" ^tests(|_.*)$" , dirname )
19+ )
20+
21+ # Is the current working directory as expected?
22+ evidences [[" pwd" ]] <- (evidences [[" tests" ]] || grepl(pattern , dirname ))
23+
24+ # Is 'R CMD check' checking examples?
25+ evidences [[" examples" ]] <- is.element(" CheckExEnv" , search())
26+
27+ # SPECIAL: win-builder?
28+ evidences [[" win-builder" ]] <- (.Platform $ OS.type == " windows" && grepl(" Rterm[.]exe$" , args [1 ]))
29+
30+ if (evidences [[" win-builder" ]]) {
31+ n <- length(args )
32+ if (all(c(" --no-save" , " --no-restore" , " --no-site-file" , " --no-init-file" ) %in% args )) {
33+ evidences [[" vanilla" ]] <- TRUE
34+ }
35+
36+ if (grepl(pattern , parent )) {
37+ evidences [[" pwd" ]] <- TRUE
38+ }
39+ }
40+
41+ if (! evidences $ vanilla || ! evidences $ pwd ) {
42+ res <- " notRunning"
43+ } else if (evidences $ tests ) {
44+ res <- " checkingTests"
45+ } else if (evidences $ examples ) {
46+ res <- " checkingExamples"
47+ } else {
48+ res <- " notRunning"
49+ }
50+
51+ attr(res , " evidences" ) <- evidences
52+
53+ res
54+ }
55+
56+ inRCmdCheck <- local({
57+ .cache <- NULL
58+ function () {
59+ if (is.null(.cache )) {
60+ .cache <<- (queryRCmdCheck() != " notRunning" )
61+ }
62+ .cache
63+ }
64+ })
65+
166future_has_evalFuture <- local({
267 res <- NULL
368 function () {
@@ -15,8 +80,8 @@ patch_expressions <- function() {
1580 if (is.null(patches )) {
1681 patches <- NA_character_
1782 if (future_has_evalFuture()) {
18- # # Package 'WARDEN'
19- if (" WARDEN" %in% loadedNamespaces()) {
83+ # # Package 'WARDEN', if 'R CMD check' is running
84+ if (" WARDEN" %in% loadedNamespaces() && inRCmdCheck() ) {
2085 patches <- c(patches , " WARDEN" )
2186 }
2287 }
0 commit comments