Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
nparley committed Feb 8, 2016
2 parents b813550 + 548cf8a commit bdf92b7
Show file tree
Hide file tree
Showing 29 changed files with 603 additions and 601 deletions.
23 changes: 6 additions & 17 deletions .travis.yml
@@ -1,24 +1,13 @@
language: r
sudo: required
language: R
cache: packages

bioc_required: true
warnings_are_errors: true
bioc_packages:
- BiocInstaller

before_script:
- git config --global user.name "travis"
- git config --global user.email "travis@example.org"

r_binary_packages:
- XML
- Rcpp
- knitr

r_github_packages:
- rstudio/rmarkdown
- hadley/testthat
- jimhester/covr
- jimhester/lintr

bioc_packages:
- BiocInstaller

after_success:
- Rscript -e 'covr::codecov()'
2 changes: 2 additions & 0 deletions NAMESPACE
@@ -1,10 +1,12 @@
# Generated by roxygen2: do not edit by hand

S3method(as.character,quietError)
S3method(format,check_results)
S3method(github_resolve_ref,"NULL")
S3method(github_resolve_ref,default)
S3method(github_resolve_ref,github_pull)
S3method(github_resolve_ref,github_release)
S3method(print,check_results)
S3method(print,doctor)
S3method(print,maintainers)
S3method(print,package_deps)
Expand Down
27 changes: 27 additions & 0 deletions NEWS.md
Expand Up @@ -4,6 +4,33 @@
for shallow git clones, i.e. git clones which make use of depth.
(#1048, #1046, @nparley)

* `check()` gains a `run_dont_test` argument to control whether or not
`\donttest{}` tests are tested. This defaults to `FALSE`, but `release()`
runs check with it set to `TRUE` (#1071).

* The `cleanup` argument to `check()` is deprecated: it now always returns
the path to the check directory.

* `use_travis()` generates a template compatible with the newest R-travis.

* `build_win()` defaults to only R-devel, since this is most commonly
what you want.

* `release()` has been tweaked to improve the order of the questions,
and ensure that you're ok with problems.

* Help shims now inform you that you're using development documentation
(#1049).

* `use_github()` prints the url of the repo (#1063).

* `use_testthat()` tells you what it's doing (#1056).

* `use_news()`, and `use_test()` open the files in RStudio (if you're using
it and have rstudioapi installed).

* `use_readme_md()` creates a basic `README.md` template (#1064).

# devtools 1.10.0

## New features
Expand Down
9 changes: 6 additions & 3 deletions R/build.r
Expand Up @@ -90,15 +90,18 @@ build <- function(pkg = ".", path = NULL, binary = FALSE, vignettes = TRUE,
#' @inheritParams build
#' @param version directory to upload to on the win-builder, controlling
#' which version of R is used to build the package. Possible options are
#' listed on \url{http://win-builder.r-project.org/}. Defaults to the
#' released version of R.
#' listed on \url{http://win-builder.r-project.org/}. Defaults to R-devel.
#' @export
#' @family build functions
build_win <- function(pkg = ".", version = c("R-release", "R-devel"),
args = NULL, quiet = FALSE) {
pkg <- as.package(pkg)

version <- match.arg(version, several.ok = TRUE)
if (missing(version)) {
version <- "R-devel"
} else {
version <- match.arg(version, several.ok = TRUE)
}

if (!quiet) {
message("Building windows version of ", pkg$package,
Expand Down
96 changes: 42 additions & 54 deletions R/check-devtools.r
Expand Up @@ -15,12 +15,11 @@ release_checks <- function(pkg = ".", built_path = NULL) {
check_dev_versions(pkg)
check_vignette_titles(pkg)
check_news_md(pkg)
check_remotes(pkg)
}

check_dev_versions <- function(pkg = ".") {
pkg <- as.package(pkg)
message("Checking for dependencies on development versions... ",
appendLF = FALSE)

dep_list <- pkg[tolower(standardise_dep(TRUE))]
deps <- do.call("rbind", unname(compact(lapply(dep_list, parse_deps))))
Expand All @@ -32,67 +31,50 @@ check_dev_versions <- function(pkg = ".") {
last_ver <- vapply(parsed, function(x) x[[length(x)]], integer(1))

is_dev <- lengths == 4 & last_ver >= 9000
if (!any(is_dev)) {
message("OK")
return(invisible(TRUE))
}

message(
"WARNING",
"\n Depends on devel versions of: ",
"\n ", paste0(deps$name[is_dev], collapse = ", "),
"\n Release these packages to CRAN and bump version number.")
check_status(
!any(is_dev),
"dependencies don't rely on dev versions",
paste(
"depends on devel versions of: ",
paste0(deps$name[is_dev], collapse = ", ")
)
)

return(invisible(FALSE))
}

check_version <- function(pkg = ".") {
pkg <- as.package(pkg)
message("Checking version number... ",
appendLF = FALSE)

ver <- unlist(numeric_version(pkg$version))
if (length(ver) == 3) {
message("OK")
return(invisible(TRUE))
}
message(
"WARNING",
"\n Version (", pkg$version, ") should have exactly three components"
)

return(invisible(FALSE))

check_status(length(ver) == 3,
"version number has three components",
paste0("version (", pkg$version, ") should have exactly three components")
)
}

check_vignette_titles <- function(pkg = ".") {
pkg <- as.package(pkg)

vigns <- tools::pkgVignettes(dir = pkg$path)
if (length(vigns$docs) == 0) return()

message("Checking vignette titles... ", appendLF = FALSE)
has_Vignette_Title <- function(v, n) {
has_vignette_title <- function(v, n) {
h <- readLines(v, n = n)
any(grepl("Vignette Title", h))
}
v <- stats::setNames(vigns$docs, basename(vigns$docs))
has_VT <- vapply(v, has_Vignette_Title, logical(1), n = 30)

if (!any(has_VT)) {
message("OK")
return(invisible(TRUE))
}

message(
"WARNING",
"\n placeholder 'Vignette Title' detected in 'title' field and/or ",
"\n 'VignetteIndexEntry' for these vignettes:\n",
paste(" ", names(has_VT)[has_VT], collapse = "\n")
has_vt <- vapply(v, has_vignette_title, logical(1), n = 30)

check_status(
!any(has_vt),
"vignette titles are not placeholders",
paste0(
"placeholder 'Vignette Title' detected in 'title' field and/or ",
"'VignetteIndexEntry' for: ",
paste(names(has_vt)[has_vt], collapse = ",")
)
)

return(invisible(FALSE))

}

check_news_md <- function(pkg) {
Expand All @@ -102,8 +84,6 @@ check_news_md <- function(pkg) {
if (!file.exists(news_path))
return()

message("Checking that NEWS.md is not ignored... ", appendLF = FALSE)

ignore_path <- file.path(pkg$path, ".Rbuildignore")
if (!file.exists(ignore_path)) {
ignore_lines <- character()
Expand All @@ -114,17 +94,25 @@ check_news_md <- function(pkg) {
has_news <- grepl("NEWS\\.md", ignore_lines, fixed = TRUE) |
grepl("NEWS.md", ignore_lines, fixed = TRUE)

if (!any(has_news)) {
message("OK")
return(invisible(TRUE))
}

message(
"WARNING",
"\n NEWS.md is in .Rbuildignore. It is now supported by CRAN ",
"\n so can be included in the package."
check_status(!any(has_news),
"NEWS.md is not ignored",
"NEWS.md now supported by CRAN and doesn't need to be ignored."
)
}

return(invisible(FALSE))
check_remotes <- function(pkg) {
check_status(!has_dev_remotes(pkg),
"DESCRIPTION doesn't have Remotes field",
"Remotes field should be removed before CRAN submission."
)
}

check_status <- function(status, name, warning) {
if (status) {
cat("Checking ", name, "... OK", "\n", sep = "")
} else {
cat("Checking ", name, "...\n", sep = "")
message("WARNING: ", warning)
}
invisible(status)
}
85 changes: 85 additions & 0 deletions R/check-results.R
@@ -0,0 +1,85 @@
parse_check_results <- function(path) {
lines <- paste(readLines(path), collapse = "\n")

# Strip off trailing NOTE and WARNING messages
lines <- gsub("^NOTE: There was .*\n$", "", lines)
lines <- gsub("^WARNING: There was .*\n$", "", lines)

pieces <- strsplit(lines, "\n\\* ")[[1]]

structure(
list(
errors = pieces[grepl("... ERROR", pieces, fixed = TRUE)],
warnings = pieces[grepl("... WARN", pieces, fixed = TRUE)],
notes = pieces[grepl("... NOTE", pieces, fixed = TRUE)]
),
path = path,
class = "check_results"
)
}

signal_check_results <- function(x, on = c("none", "error", "warning", "note")) {
has <- lapply(x, function(x) length(x) > 0)

on <- match.arg(on)
has_problem <- switch(on,
none = FALSE,
error = has$errors,
warning = has$errors | has$warnings,
note = has$errors | has$warnings | has$notes
)

if (has_problem) {
stop(summarise_check_results(x), call. = FALSE)
}
invisible(TRUE)
}

#' @export
print.check_results <- function(x, ...) {
message("R CMD check results")
message(summarise_check_results(x))

cat(format(x), "\n", sep = "")
invisible(x)
}

#' @export
format.check_results <- function(x, ...) {
paste0(unlist(x), collapse = "\n\n")
}

summarise_check_results <- function(x) {
n <- lapply(x, length)
paste0(
n$errors, " ", ngettext(n$errors, "error", "errors"), " | ",
n$warnings, " ", ngettext(n$warnings, "warning", "warnings"), " | ",
n$notes, " ", ngettext(n$notes, "note", "notes")
)
}

#' Parses R CMD check log file for ERRORs, WARNINGs and NOTEs
#'
#' Extracts check messages from the \code{00check.log} file generated by
#' \code{R CMD check}.
#'
#' @param path check path, e.g., value of the \code{check_dir} argument in a
#' call to \code{\link{check}}
#' @param error,warning,note logical, indicates if errors, warnings and/or
#' notes should be returned
#' @return a character vector with the relevant messages, can have length zero
#' if no messages are found
#'
#' @seealso \code{\link{check}}, \code{\link{revdep_check}}
#' @export
check_failures <- function(path, error = TRUE, warning = TRUE, note = TRUE) {
check_dir <- file.path(path, "00check.log")

results <- parse_check_results(check_dir)

c(
if (error) results$errors,
if (warning) results$warnings,
if (note) results$notes
)
}

0 comments on commit bdf92b7

Please sign in to comment.