diff --git a/DESCRIPTION b/DESCRIPTION index 53df9ed2d..3e5e91d7c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,7 +31,8 @@ Imports: withr, pkgbuild, pkgload, - sessioninfo + sessioninfo, + rcmdcheck Suggests: curl (>= 0.9), crayon, diff --git a/NEWS.md b/NEWS.md index 5831cfcb3..fdb875b34 100644 --- a/NEWS.md +++ b/NEWS.md @@ -33,6 +33,7 @@ * `source_gist()` works once more when there is only a single file in the gist (#1266). * Infrastructure functions (`use_*`) now use the implementations in **usethis**. +* Use rcmdcheck to run and parse R CMD check output (#1153). # devtools 1.13.2 Workaround a regression in Rcpp::compileAttributes. diff --git a/R/check.r b/R/check.r index 1c70983ca..347210da5 100644 --- a/R/check.r +++ b/R/check.r @@ -59,8 +59,7 @@ check <- function(pkg = ".", run_dont_test = FALSE, args = NULL, env_vars = NULL, - quiet = FALSE, - check_dir = tempdir()) { + quiet = FALSE) { pkg <- as.package(pkg) # document only if package uses roxygen, i.e. has RoxygenNote field @@ -97,9 +96,7 @@ check <- function(pkg = ".", manual = manual, args = args, env_vars = env_vars, - quiet = quiet, - check_dir = check_dir, - needs_build_tools = pkgbuild::pkg_has_src(pkg$path) + quiet = quiet ) } @@ -121,15 +118,11 @@ check <- function(pkg = ".", #' (\code{--no-manual}). #' @param args Additional arguments passed to \code{R CMD check} #' @param env_vars Environment variables set during \code{R CMD check} -#' @param needs_build_tools If \code{TRUE}, will ensure build tools are -#' available when checking the package. -#' @param check_dir the directory in which the package is checked #' @param quiet if \code{TRUE} suppresses output from this function. check_built <- function(path = NULL, cran = TRUE, check_version = FALSE, force_suggests = FALSE, run_dont_test = FALSE, manual = FALSE, args = NULL, - env_vars = NULL, needs_build_tools = TRUE, - check_dir = tempdir(), quiet = FALSE) { + env_vars = NULL, quiet = FALSE) { pkgname <- gsub("_.*?$", "", basename(path)) @@ -160,29 +153,9 @@ check_built <- function(path = NULL, cran = TRUE, rule("Checking ", pkgname) } - pkgbuild::rcmd_build_tools( - "check", - c(path, args), - wd = check_dir, - env = env_vars, - echo = !quiet, - show = !quiet, - required = needs_build_tools - ) - - package_path <- file.path( - normalizePath(check_dir), - paste(pkgname, ".Rcheck", sep = "") - ) - if (!file.exists(package_path)) { - stop("Check failed: '", package_path, "' doesn't exist", call. = FALSE) - } - - # Record successful completion - writeLines("OK", file.path(package_path, "COMPLETE")) - - log_path <- file.path(package_path, "00check.log") - parse_check_results(log_path) + withr::with_envvar(env_vars, action = "prefix", { + rcmdcheck::rcmdcheck(path, quiet = quiet, args = args) + }) } check_env_vars <- function(cran = FALSE, check_version = FALSE, diff --git a/man/check.Rd b/man/check.Rd index 231319ceb..f14b2f4f8 100644 --- a/man/check.Rd +++ b/man/check.Rd @@ -7,13 +7,11 @@ \usage{ check(pkg = ".", document = NA, build_args = NULL, ..., manual = FALSE, cran = TRUE, check_version = FALSE, force_suggests = FALSE, - run_dont_test = FALSE, args = NULL, env_vars = NULL, quiet = FALSE, - check_dir = tempdir()) + run_dont_test = FALSE, args = NULL, env_vars = NULL, quiet = FALSE) check_built(path = NULL, cran = TRUE, check_version = FALSE, force_suggests = FALSE, run_dont_test = FALSE, manual = FALSE, - args = NULL, env_vars = NULL, needs_build_tools = TRUE, - check_dir = tempdir(), quiet = FALSE) + args = NULL, env_vars = NULL, quiet = FALSE) } \arguments{ \item{pkg}{package description, can be path or package name. See @@ -51,12 +49,7 @@ submission.} \item{quiet}{if \code{TRUE} suppresses output from this function.} -\item{check_dir}{the directory in which the package is checked} - \item{path}{Path to built package.} - -\item{needs_build_tools}{If \code{TRUE}, will ensure build tools are -available when checking the package.} } \value{ An object containing errors, warnings, and notes.