Skip to content
Snippets Groups Projects
Commit 34136bc0 authored by Mick Jordan's avatar Mick Jordan
Browse files

pkgtest: support vignettes and install Suggests

parent 3a01b06a
No related branches found
No related tags found
No related merge requests found
...@@ -122,11 +122,15 @@ default.packages <- c("R", "base", "grid", "splines", "utils", ...@@ -122,11 +122,15 @@ default.packages <- c("R", "base", "grid", "splines", "utils",
"compiler", "grDevices", "methods", "stats", "stats4", "compiler", "grDevices", "methods", "stats", "stats4",
"datasets", "graphics", "parallel", "tools", "tcltk") "datasets", "graphics", "parallel", "tools", "tcltk")
# returns a vector of package names that are the direct dependents of pkg choice.depends <- function(pkg, choice=c("direct","suggests")) {
direct.depends <- function(pkg) { if (choice == "direct") {
depends <- c("Depends", "Imports", "LinkingTo")
} else {
depends <- "Suggests"
}
pkgName <- pkg["Package"] pkgName <- pkg["Package"]
all.deps <- character() all.deps <- character()
for (dep in c("Depends", "Imports", "LinkingTo")) { for (dep in depends) {
deps <- pkg[dep] deps <- pkg[dep]
if (!is.na(deps)) { if (!is.na(deps)) {
if (very.verbose) { if (very.verbose) {
...@@ -141,8 +145,20 @@ direct.depends <- function(pkg) { ...@@ -141,8 +145,20 @@ direct.depends <- function(pkg) {
unname(all.deps) unname(all.deps)
} }
# returns a vector of package names that are the direct dependents of pkg
direct.depends <- function(pkg) {
choice.depends(pkg, "direct")
}
# returns a vector of package names that are the "Suggests" dependents of pkg
suggest.depends <- function(pkg) {
choice.depends(pkg, "suggests")
}
# returns the transitive set of dependencies in install order # returns the transitive set of dependencies in install order
install.order <- function(pkgs, pkg, depth=0L) { # the starting set of dependencies may be "direct" or "suggests"
# although once we start recursing, it becomes "direct"
install.order <- function(pkgs, pkg, choice, depth=0L) {
ndup.append <- function(v, name) { ndup.append <- function(v, name) {
if (!name %in% v) { if (!name %in% v) {
...@@ -153,12 +169,12 @@ install.order <- function(pkgs, pkg, depth=0L) { ...@@ -153,12 +169,12 @@ install.order <- function(pkgs, pkg, depth=0L) {
pkgName <- pkg["Package"] pkgName <- pkg["Package"]
result <- character() result <- character()
directs <- direct.depends(pkg) depends <- choice.depends(pkg, choice)
for (direct in directs) { for (depend in depends) {
# check it is in avail.pkgs (cran) # check it is in avail.pkgs (cran)
if (direct %in% avail.pkgs.rownames) { if (depend %in% avail.pkgs.rownames) {
direct.result <- install.order(pkgs, pkgs[direct, ], depth=depth + 1) depend.result <- install.order(pkgs, pkgs[depend, ], "direct", depth=depth + 1)
for (dr in direct.result) { for (dr in depend.result) {
result <- ndup.append(result, dr) result <- ndup.append(result, dr)
} }
} }
...@@ -434,7 +450,7 @@ get.pkgs <- function() { ...@@ -434,7 +450,7 @@ get.pkgs <- function() {
# If dependents.install=T, this is a nested install of the dependents # If dependents.install=T, this is a nested install of the dependents
# of one of the initial list. N.B. In this case pkgnames is the # of one of the initial list. N.B. In this case pkgnames is the
# transitively computed list so this never recurses more than one level # transitively computed list so this never recurses more than one level
install.pkgs <- function(pkgnames, dependents.install=F) { install.pkgs <- function(pkgnames, dependents.install=F, log=T) {
if (verbose && !dry.run) { if (verbose && !dry.run) {
cat("packages to install (+dependents):\n") cat("packages to install (+dependents):\n")
for (pkgname in pkgnames) { for (pkgname in pkgnames) {
...@@ -445,10 +461,12 @@ install.pkgs <- function(pkgnames, dependents.install=F) { ...@@ -445,10 +461,12 @@ install.pkgs <- function(pkgnames, dependents.install=F) {
install.total <- length(pkgnames) install.total <- length(pkgnames)
result <- TRUE result <- TRUE
for (pkgname in pkgnames) { for (pkgname in pkgnames) {
cat("BEGIN processing:", pkgname, "\n") if (log) {
cat("BEGIN processing:", pkgname, "\n")
}
dependent.install.ok <- T dependent.install.ok <- T
if (install.dependents.first && !dependents.install) { if (install.dependents.first && !dependents.install) {
dependents <- install.order(avail.pkgs, avail.pkgs[pkgname, ]) dependents <- install.order(avail.pkgs, avail.pkgs[pkgname, ], "direct")
if (length(dependents) > 0) { if (length(dependents) > 0) {
# not a leaf package # not a leaf package
dep.status <- install.status[dependents] dep.status <- install.status[dependents]
...@@ -506,13 +524,39 @@ install.pkgs <- function(pkgnames, dependents.install=F) { ...@@ -506,13 +524,39 @@ install.pkgs <- function(pkgnames, dependents.install=F) {
} }
} }
} }
cat("END processing:", pkgname, "\n") if (log) {
cat("END processing:", pkgname, "\n")
}
install.count = install.count + 1 install.count = install.count + 1
} }
return(result) return(result)
} }
install.suggests <- function(pkgnames) {
for (pkgname in pkgnames) {
suggests <- install.order(avail.pkgs, avail.pkgs[pkgname, ], "suggests")
if (length(suggests) > 0) {
dep.status <- install.status[suggests]
# three cases:
# 1. all TRUE: nothing to do all already installed ok
# 2. any FALSE: ignore; tests will fail but that's ok
# 3. a mixture of TRUE and NA: ok, but some more to install (the NAs)
if (any(!dep.status, na.rm=T)) {
# case 2
cat("not installing Suggests of:", pkgname, ", one or more previously failed", "\n")
} else {
if (anyNA(dep.status)) {
# case 3
cat("installing Suggests of:", pkgname, "\n")
dependent.install.ok <- install.pkgs(suggests, dependents.install=T, log=F)
} else {
# case 1
}
}
}
}
}
get.blacklist <- function() { get.blacklist <- function() {
if (create.blacklist.file) { if (create.blacklist.file) {
...@@ -574,6 +618,11 @@ do.it <- function() { ...@@ -574,6 +618,11 @@ do.it <- function() {
show.install.status(test.pkgnames) show.install.status(test.pkgnames)
} }
# need to install the Suggests packages as they may be used
cat('BEGIN suggests install\n')
install.suggests(test.pkgnames)
cat('END suggests install\n')
cat("BEGIN package tests\n") cat("BEGIN package tests\n")
test.count = 1 test.count = 1
test.total = length(test.pkgnames) test.total = length(test.pkgnames)
...@@ -846,8 +895,8 @@ get.initial.package.blacklist <- function() { ...@@ -846,8 +895,8 @@ get.initial.package.blacklist <- function() {
} }
} }
run <- function() { run.setup <- function() {
parse.args() parse.args()
check.libs() check.libs()
check.pkgfilelist() check.pkgfilelist()
set.contriburl() set.contriburl()
...@@ -855,6 +904,10 @@ run <- function() { ...@@ -855,6 +904,10 @@ run <- function() {
set.package.blacklist() set.package.blacklist()
lib.install <<- normalizePath(lib.install) lib.install <<- normalizePath(lib.install)
cat.args() cat.args()
}
run <- function() {
run.setup()
do.it() do.it()
} }
......
...@@ -43,8 +43,7 @@ run <- function() { ...@@ -43,8 +43,7 @@ run <- function() {
if (!file.exists(outDir)) { if (!file.exists(outDir)) {
dir.create(outDir) dir.create(outDir)
} }
# TODO add vignettes to types when practical tools:::testInstalledPackage(pkgname, outDir=outDir, lib.loc=lib.install, types=c("examples", "tests", "vignettes"))
tools:::testInstalledPackage(pkgname, outDir=outDir, lib.loc=lib.install, types=c("examples", "tests"))
} }
if (!interactive()) { if (!interactive()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment