Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

check: make CRAN version check optional. Fixes #172

This commit also switches from using --as-cran, to setting environment
variables, as described in R Internals.
  • Loading branch information...
commit 59ef32a1e7d99ed576a489b79c23da78db854173 1 parent 4663654
@wch wch authored
Showing with 32 additions and 10 deletions.
  1. +28 −7 R/check.r
  2. +1 −1  R/release.r
  3. +3 −2 R/system.r
View
35 R/check.r
@@ -16,11 +16,13 @@
#' is successful - this allows you to inspect the results to figure out what
#' went wrong. If \code{FALSE} the check directory is never removed.
#' @param cran if \code{TRUE} (the default), check with CRAN.
+#' @param check_version if \code{TRUE}, check that the new version is greater
+#' than the current version on CRAN.
#' @param args An optional character vector of additional command line
#' arguments to be passed to \code{R CMD check}.
#' @export
check <- function(pkg = ".", document = TRUE, cleanup = TRUE,
- cran = TRUE, args = NULL) {
+ cran = TRUE, check_version = FALSE, args = NULL) {
pkg <- as.package(pkg)
if (document) {
@@ -30,7 +32,7 @@ check <- function(pkg = ".", document = TRUE, cleanup = TRUE,
built_path <- build(pkg, tempdir())
on.exit(unlink(built_path))
- r_cmd_check_path <- check_r_cmd(built_path, cran, args)
+ r_cmd_check_path <- check_r_cmd(built_path, cran, check_version, args)
check_devtools(pkg, built_path)
@@ -48,17 +50,36 @@ check <- function(pkg = ".", document = TRUE, cleanup = TRUE,
# Run R CMD check and return the path for the check
# @param built_path The path to the built .tar.gz source package.
# @param check_dir The directory to unpack the .tar.gz file to
-check_r_cmd <- function(built_path = NULL, cran = TRUE, args = NULL,
- check_dir = tempdir()) {
+check_r_cmd <- function(built_path = NULL, cran = TRUE, check_version = FALSE,
+ args = NULL, check_dir = tempdir()) {
pkgname <- gsub("_.*?$", "", basename(built_path))
opts <- "--timings"
- if (cran)
- opts <- c(opts, "--as-cran")
opts <- paste(paste(opts, collapse = " "), paste(args, collapse = " "))
- R(paste("CMD check ", shQuote(built_path), " ", opts, sep = ""), check_dir)
+ env_vars <- NULL
+ if (cran) {
+ # These environment variables are from the R Internals document. The only
+ # difference from that document is that here, _R_CHECK_CRAN_INCOMING_ is
+ # not set to TRUE.
+ env_vars <- c(env_vars,
+ "_R_CHECK_VC_DIRS_" = "TRUE",
+ "_R_CHECK_TIMINGS_" = "10",
+ "_R_CHECK_INSTALL_DEPENDS_" = "TRUE",
+ "_R_CHECK_SUGGESTS_ONLY_" = "TRUE",
+ "_R_CHECK_NO_RECOMMENDED_" = "TRUE",
+ "_R_CHECK_EXECUTABLES_EXCLUSIONS_" = "FALSE",
+ "_R_CHECK_DOC_SIZES2_" = "TRUE"
+ )
+ }
+
+ if (check_version) {
+ env_vars <- c(env_vars, "_R_CHECK_CRAN_INCOMING_" = "TRUE")
+ }
+
+ R(paste("CMD check ", shQuote(built_path), " ", opts, sep = ""), check_dir,
+ env_vars)
# Return the path to the check output
file.path(tempdir(), paste(pkgname, ".Rcheck", sep = ""))
View
2  R/release.r
@@ -33,7 +33,7 @@ release <- function(pkg = ".", check = TRUE) {
pkg <- as.package(pkg)
if (check) {
- check(pkg)
+ check(pkg, cran = TRUE, check_version = TRUE)
if (yesno("Was package check successful?"))
return(invisible())
}
View
5 R/system.r
@@ -15,7 +15,7 @@ system_check <- function(cmd, args = character(), env = character(), ...) {
invisible(TRUE)
}
-R <- function(options, path = tempdir(), ...) {
+R <- function(options, path = tempdir(), env_vars = NULL, ...) {
options <- paste("--vanilla", options)
r_path <- file.path(R.home("bin"), "R")
@@ -23,7 +23,8 @@ R <- function(options, path = tempdir(), ...) {
"LC_ALL" = "C",
"R_LIBS" = paste(.libPaths(), collapse = .Platform$path.sep),
"CYGWIN" = "nodosfilewarning",
- "R_TESTS" = "")
+ "R_TESTS" = "",
+ env_vars)
# When R CMD check runs tests, it sets R_TESTS. When the tests
# themeselves run R CMD xxxx, as is the case with the tests in
# devtools, having R_TESTS set causes errors because it confuses
Please sign in to comment.
Something went wrong with that request. Please try again.