Permalink
Browse files

Move call to extra file check from build() to check()

  • Loading branch information...
1 parent e496a9b commit cea4fa8e1723fc723b4e0e11a9534fc3662154e2 @wch wch committed Sep 12, 2012
Showing with 63 additions and 53 deletions.
  1. +7 −6 DESCRIPTION
  2. +0 −44 R/build.r
  3. +3 −3 R/check.r
  4. +53 −0 R/check_devtools.r
View
@@ -1,12 +1,12 @@
Package: devtools
Title: Tools to make developing R code easier
Version: 0.8
-Authors@R: c(
- person("Hadley", "Wickham",
- email = "h.wickham@gmail.com", role = c("aut", "cre")),
- person("Winston", "Chang", role = "aut"),
- person("R Core team", role = "ctb",
- comment = "Namespace related code extracted out of base R"))
+Authors@R: c(
+ person("Hadley", "Wickham",
+ email = "h.wickham@gmail.com", role = c("aut", "cre")),
+ person("Winston", "Chang", role = "aut"),
+ person("R Core team", role = "ctb",
+ comment = "Namespace related code extracted out of base R"))
Description: Collection of package development tools
Depends:
R (>= 2.15)
@@ -77,3 +77,4 @@ Collate:
'dev-example.r'
'run-example.r'
'dev-help.r'
+ 'check_devtools.r'
View
@@ -28,8 +28,6 @@ build <- function(pkg = ".", path = NULL, binary = FALSE) {
targz <- paste(pkg$package, "_", pkg$version, ".", ext, sep = "")
- check_pkg_extra_files(pkg$package, file.path(path, targz))
-
file.path(path, targz)
}
@@ -62,45 +60,3 @@ build_win <- function(pkg = ".", version = "R-release") {
"/", basename(built_path), sep = ""))
invisible()
}
-
-
-# This checks for extra files in a built package source .tar.gz file
-#
-# @param pkgname The name of the package
-# @param pkg_targz An R source package tar.gz file
-check_pkg_extra_files <- function(pkgname, pkg_targz) {
- message("devtools is checking for any extra files in built .tar.gz file... ",
- appendLF = FALSE)
-
- # Get unique second-level paths of all files in the tar.gz file.
- # If file is "gtable/man/gtable.Rd", second-level path is "man"
- files <- untar(pkg_targz, compressed = "gzip", list = TRUE)
- files <- sub(paste("^", pkgname, "/", sep=""), "", files)
- files <- sub("/.*$", "", files)
- files <- unique(files)
-
- # These are the files that are officially required in a source package,
- # according to "Writing R Extensions"
- req_files <- c("DESCRIPTION", "R", "data", "demo", "exec", "inst",
- "man", "po", "src", "tests")
- # Files that are optional in a source package, according to the doc
- opt_files <- c("INDEX", "NAMESPACE", "configure", "cleanup", "LICENSE",
- "LICENCE", "NEWS")
-
- # These are other common files in a source package
- other_files <- c("", "build", "CHANGELOG", "INSTALL", "README",
- "README.md")
-
- # Now remove all the OK paths from the list; what remains are bad paths
- files <- files[!(files %in% c(req_files, opt_files, other_files))]
-
- if (length(files) > 0) {
- message("\n Non-standard files found:\n ",
- paste(files, collapse="\n "),
- "\n Did you intend to include these files?\n")
- } else {
- message("OK")
- }
-
- invisible()
-}
View
@@ -23,7 +23,7 @@ check <- function(pkg = ".", document = TRUE, cleanup = TRUE,
if (document) {
document(pkg, clean = TRUE)
}
- message("Checking ", pkg$package)
+ message("Checking ", pkg$package, " with R CMD check")
built_path <- build(pkg, tempdir())
on.exit(unlink(built_path))
@@ -34,6 +34,8 @@ check <- function(pkg = ".", document = TRUE, cleanup = TRUE,
opts <- paste(paste(opts, collapse = " "), paste(args, collapse = " "))
R(paste("CMD check ", shQuote(built_path), " ", opts, sep = ""), tempdir())
+
+ check_devtools(pkg, built_path)
check_path <- file.path(tempdir(), paste(pkg$package, ".Rcheck",
sep = ""))
@@ -45,5 +47,3 @@ check <- function(pkg = ".", document = TRUE, cleanup = TRUE,
invisible(TRUE)
}
-
-
View
@@ -0,0 +1,53 @@
+# Run devtools-specific checks on a built package
+# (Don't export for now, since we'll want to think about whether this
+# should be run on package source dirs or just built tar.gz files)
+# @pkg A package object
+# @built_path The path to a tar.gz file of the built source package
+check_devtools <- function(pkg = ".", built_path) {
+ pkg <- as.package(pkg)
+ message("Checking ", pkg$package, " with devtools")
+
+ check_pkg_extra_files(pkg$package, built_path)
+}
+
+
+# This checks for extra files in a built package source .tar.gz file
+#
+# @param pkgname The name of the package
+# @param built_path An R source package tar.gz file
+check_pkg_extra_files <- function(pkgname, built_path) {
+ message("Checking for any extra files in built .tar.gz file... ",
+ appendLF = FALSE)
+
+ # Get unique second-level paths of all files in the tar.gz file.
+ # If file is "gtable/man/gtable.Rd", second-level path is "man"
+ files <- untar(built_path, compressed = "gzip", list = TRUE)
+ files <- sub(paste("^", pkgname, "/", sep=""), "", files)
+ files <- sub("/.*$", "", files)
+ files <- unique(files)
+
+ # These are the files that are officially required in a source package,
+ # according to "Writing R Extensions"
+ req_files <- c("DESCRIPTION", "R", "data", "demo", "exec", "inst",
+ "man", "po", "src", "tests")
+ # Files that are optional in a source package, according to the doc
+ opt_files <- c("INDEX", "NAMESPACE", "configure", "cleanup", "LICENSE",
+ "LICENCE", "NEWS")
+
+ # These are other common files in a source package
+ other_files <- c("", "build", "CHANGELOG", "INSTALL", "README",
+ "README.md")
+
+ # Now remove all the OK paths from the list; what remains are bad paths
+ files <- files[!(files %in% c(req_files, opt_files, other_files))]
+
+ if (length(files) > 0) {
+ message("\n Non-standard files found:\n ",
+ paste(files, collapse="\n "),
+ "\n Did you intend to include these files?\n")
+ } else {
+ message("OK")
+ }
+
+ invisible()
+}

0 comments on commit cea4fa8

Please sign in to comment.