@@ -28,16 +28,18 @@ check <- function() {
2828 cat(sprintf(" R CMD check will use env vars from %s\n " , sQuote(p )))
2929 cat(sprintf(" To disable, set 'R_CHECK_ENVIRON=false' (a fake pathname)\n " ))
3030 }
31-
32- envs <- grep(" ^_R_CHECK_" , names(Sys.getenv()), value = TRUE )
31+
32+ envs <- Sys.getenv()
33+ envs <- envs [grep(" ^_?R_CHECK_" , names(envs ))]
3334 if (length(envs ) > 0L ) {
34- cat(sprintf(" Detected _R_CHECK_* env vars that will affect R CMD check: %s\n " ,
35- paste(sQuote(envs ), collapse = " , " )))
35+ envs <- sprintf(" %02d. %s=%s" , seq_along(envs ), names(envs ), envs )
36+ envs <- paste(envs , collapse = " \n " )
37+ cat(sprintf(" Detected R-specific env vars that may affect R CMD check:\n %s\n " , envs ))
3638 }
3739
3840 precheck()
3941 revdep_check(bioc = TRUE , num_workers = available_cores(),
40- timeout = as.difftime(20 , units = " mins" ), quiet = FALSE )
42+ timeout = as.difftime(30 , units = " mins" ), quiet = FALSE )
4143}
4244
4345
@@ -72,10 +74,18 @@ revdep_todo_reset <- function() {
7274 DBI :: dbWriteTable(db , " todo" , df , overwrite = TRUE , append = FALSE )
7375}
7476
77+ revdep_this_package <- local({
78+ pkg <- NULL
79+ function () {
80+ if (is.null(pkg )) pkg <<- desc :: desc(file = " DESCRIPTION" )$ get(" Package" )
81+ pkg
82+ }
83+ })
84+
7585revdep_children <- local({
7686 cache <- list ()
7787 function (pkg = NULL ) {
78- if (is.null(pkg )) pkg <- desc :: desc( file = " DESCRIPTION " ) $ get( " Package " )
88+ if (is.null(pkg )) pkg <- revdep_this_package( )
7989 pkgs <- cache [[pkg ]]
8090 if (is.null(pkgs )) {
8191 pkgs <- revdepcheck ::: cran_revdeps(pkg )
@@ -86,6 +96,37 @@ revdep_children <- local({
8696 }
8797})
8898
99+ revdep_pkgs_with_status <- function (status = " error" ) {
100+ status <- match.arg(status )
101+ res <- revdepcheck :: revdep_summary()
102+ field <- switch (status , error = " errors" )
103+ has_status <- vapply(res , FUN = function (x ) {
104+ z <- x [[" new" ]][[field ]]
105+ is.character(z ) && any(nchar(z ) > 0 )
106+ }, FUN.VALUE = NA , USE.NAMES = TRUE )
107+ has_status <- ! is.na(has_status ) & has_status
108+ names(has_status )[has_status ]
109+ }
110+
111+ revdep_preinstall <- function (pkgs ) {
112+ pkgs <- unique(pkgs )
113+ lib_paths_org <- lib_paths <- .libPaths()
114+ on.exit(.libPaths(lib_paths_org ))
115+ lib_paths [1 ] <- sprintf(" %s-revdepcheck" , lib_paths [1 ])
116+ dir.create(lib_paths [1 ], recursive = TRUE , showWarnings = FALSE )
117+ .libPaths(lib_paths )
118+ message(sprintf(" Triggering crancache builds by pre-installing %d packages: %s" , length(pkgs ), paste(sQuote(pkgs ), collapse = " , " )))
119+ message(" .libPaths():" )
120+ message(paste(paste0(" - " , .libPaths()), collapse = " \n " ))
121+ # # Install one-by-one to update cache sooner
122+ for (kk in seq_along(pkgs )) {
123+ pkg <- pkgs [kk ]
124+ message(sprintf(" Pre-installing package %d of %d: %s" ,
125+ kk , length(pkgs ), pkg ))
126+ crancache :: install_packages(pkg )
127+ }
128+ }
129+
89130args <- base :: commandArgs()
90131if (" --reset" %in% args ) {
91132 revdep_reset()
@@ -125,10 +166,41 @@ if ("--reset" %in% args) {
125166 pkgs <- unique(pkgs )
126167 revdep_add(packages = pkgs )
127168 todo()
128- } else if (" --install" %in% args ) {
129- pos <- which(" --install" == args )
169+ } else if (" --show-check" %in% args ) {
170+ pos <- which(" --show-check" == args )
171+ pkgs <- parse_pkgs(args [seq(from = pos + 1L , to = length(args ))])
172+ for (pkg in pkgs ) {
173+ for (dir in c(" old" , " new" )) {
174+ path <- file.path(" revdep" , " checks" , pkg , dir , sprintf(" %s.Rcheck" , pkg ))
175+ if (! utils :: file_test(" -d" , path )) next
176+ pathname <- file.path(path , " 00check.log" )
177+ cat(" -----------------------------------------------\n " )
178+ cat(sprintf(" %s (%s):\n " , pkg , dir ))
179+ cat(" -----------------------------------------------\n " )
180+ bfr <- readLines(pathname , warn = FALSE )
181+ tail <- tail(bfr , n = 20L )
182+ writeLines(tail )
183+ }
184+ }
185+ } else if (" --list-children" %in% args ) {
186+ pkg <- revdep_this_package()
187+ pkgs <- revdepcheck ::: cran_revdeps(pkg )
188+ cat(sprintf(" [n=%d] %s\n " , length(pkgs ), paste(pkgs , collapse = " " )))
189+ } else if (" --list-error" %in% args ) {
190+ cat(paste(revdep_pkgs_with_status(" error" ), collapse = " " ), " \n " , sep = " " )
191+ } else if (" --add-error" %in% args ) {
192+ revdepcheck :: revdep_add(packages = revdep_pkgs_with_status(" error" ))
193+ } else if (" --preinstall-children" %in% args ) {
194+ pkg <- revdep_this_package()
195+ pkgs <- revdepcheck ::: cran_revdeps(pkg )
196+ revdep_preinstall(pkgs )
197+ } else if (" --preinstall-error" %in% args ) {
198+ res <- revdepcheck :: revdep_summary()
199+ revdep_preinstall(revdep_pkgs_with_status(" error" ))
200+ } else if (" --preinstall" %in% args ) {
201+ pos <- which(" --preinstall" == args )
130202 pkgs <- parse_pkgs(args [seq(from = pos + 1L , to = length(args ))])
131- crancache :: install_packages (pkgs )
203+ revdep_preinstall (pkgs )
132204} else {
133205 check()
134206 revdep_report(all = TRUE )
0 commit comments