Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions r-base/check.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

source("/includes/validate-settings.R")
source("/includes/register-dependencies.R")
source("/includes/parse-args.R")

suppressPackageStartupMessages(stopifnot(require(devtools)))
suppressPackageStartupMessages(stopifnot(require(roxygen2)))
Expand All @@ -17,9 +18,18 @@ if (!file.exists("DESCRIPTION")) {
stop("Can't do check: not a package\n")
}

cat("Looks like a package...\n"); Sys.sleep(1)
cat("Looks like a package...\n")
Sys.sleep(1)
devtools::install(PKG, dependencies = TRUE)
res <- devtools::check(PKG, error_on = "never")
cat(
"Starting package checks on",
PKG,
"with cran option set to",
cran_arg,
"...\n"
)
Sys.sleep(1)
res <- devtools::check(PKG, cran = cran_arg, error_on = "never")

LIB$errors$check(res)
LIB$warnings$check(res)
Expand Down
34 changes: 34 additions & 0 deletions r-base/parse-args.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# parse command line arguments
parse_args <- function(args) {
arg_list <- list()
for (arg in args) {
if (grepl("^--", arg)) {
arg_name_value <- sub("^--", "", arg)
if (grepl("=", arg_name_value)) {
splits <- strsplit(arg_name_value, "=")[[1]]
arg_list[[splits[1]]] <- splits[2]
} else {
arg_list[[arg_name_value]] <- TRUE
}
}
}
return(arg_list)
}

usage <- function() {
cat("Usage: check [--cran=TRUE|FALSE]\n")
}

# set default value
cran_arg <- TRUE

args <- commandArgs(trailingOnly = TRUE)
arg_list <- parse_args(args)

# check command line argument
if (length(args) > 0 && !is.null(arg_list$cran)) {
cran_arg <- as.logical(arg_list$cran)
} elseif (length(args) > 0) {
usage_message()
quit(status = 1)
}