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

pkgtest: fix bug when tested packages is already installed

parent 2f7e9d37
Branches
No related tags found
No related merge requests found
...@@ -414,28 +414,34 @@ get.pkgs <- function() { ...@@ -414,28 +414,34 @@ get.pkgs <- function() {
in.installed <- function(x) x["Package"] %in% installed.pkgs in.installed <- function(x) x["Package"] %in% installed.pkgs
basic.exclude <- function(x) { basic.exclude <- function(x, exclude.installed = T) {
in.installed(x) || in.blacklist(x) in.blacklist(x) || ifelse(exclude.installed, in.installed(x), F)
} }
# either pkg.pattern is set or pkg.filelist but not both (checked earlier) set.match.fun <- function(exclude.installed = T) {
# if inverting, alter sense of the basic match but still exclude blacklist/installed # either pkg.pattern is set or pkg.filelist but not both (checked earlier)
if (!is.na(pkg.filelistfile)) { # if inverting, alter sense of the basic match but still exclude blacklist/installed
if (invert.pkgset) { if (!is.na(pkg.filelistfile)) {
match.fun <- function(x) !in.filelist(x) && !basic.exclude(x) if (invert.pkgset) {
} else { match.fun <- function(x) !in.filelist(x) && !basic.exclude(x, exclude.installed)
match.fun <- function(x) in.filelist(x) && !basic.exclude(x) } else {
} match.fun <- function(x) in.filelist(x) && !basic.exclude(x, exclude.installed)
} else { }
if (invert.pkgset) {
match.fun <- function(x) !in.pattern(x) && !basic.exclude(x)
} else { } else {
match.fun <- function(x) in.pattern(x) && !basic.exclude(x) if (invert.pkgset) {
match.fun <- function(x) !in.pattern(x) && !basic.exclude(x, exclude.installed)
} else {
match.fun <- function(x) in.pattern(x) && !basic.exclude(x, exclude.installed)
}
} }
} }
match.fun <- set.match.fun()
matched.avail.pkgs <- apply(avail.pkgs, 1, match.fun) matched.avail.pkgs <- apply(avail.pkgs, 1, match.fun)
toinstall.pkgs <<-avail.pkgs[matched.avail.pkgs, , drop=F] toinstall.pkgs <<- avail.pkgs[matched.avail.pkgs, , drop=F]
if (length(toinstall.pkgs) == 0) {
if (length(toinstall.pkgs) == 0 && !use.installed.pkgs) {
print("Fatal error: requested package(s) found in repo(s)") print("Fatal error: requested package(s) found in repo(s)")
quit(save="no", status=100) quit(save="no", status=100)
...@@ -450,15 +456,22 @@ get.pkgs <- function() { ...@@ -450,15 +456,22 @@ get.pkgs <- function() {
test.pkgnames[[i]] <- test.avail.pkgnames[[rands[[i]]]] test.pkgnames[[i]] <- test.avail.pkgnames[[rands[[i]]]]
} }
} else { } else {
test.pkgnames <- rownames(toinstall.pkgs) if (length(toinstall.pkgs) == 0) {
if (!is.na(count.daily)) { # use.installed.pkgs == TRUE (see above)
# extract count from index given by yday match.fun <- set.match.fun(F)
npkgs <- length(test.pkgnames) matched.avail.pkgs <- apply(avail.pkgs, 1, match.fun)
yday <- as.POSIXlt(Sys.Date())$yday test.pkgnames <- rownames(avail.pkgs[matched.avail.pkgs, , drop=F])
chunk <- as.integer(npkgs / count.daily) } else {
start <- (yday %% chunk) * count.daily test.pkgnames <- rownames(toinstall.pkgs)
end <- ifelse(start + count.daily > npkgs, npkgs, start + count.daily - 1) if (!is.na(count.daily)) {
test.pkgnames <- test.pkgnames[start:end] # extract count from index given by yday
npkgs <- length(test.pkgnames)
yday <- as.POSIXlt(Sys.Date())$yday
chunk <- as.integer(npkgs / count.daily)
start <- (yday %% chunk) * count.daily
end <- ifelse(start + count.daily > npkgs, npkgs, start + count.daily - 1)
test.pkgnames <- test.pkgnames[start:end]
}
} }
} }
...@@ -880,6 +893,9 @@ parse.args <- function() { ...@@ -880,6 +893,9 @@ parse.args <- function() {
if (is.na(pkg.pattern) && is.na(pkg.filelistfile)) { if (is.na(pkg.pattern) && is.na(pkg.filelistfile)) {
pkg.pattern <<- "^.*" pkg.pattern <<- "^.*"
} }
if (!install) {
use.installed.pkgs <<- T
}
# list.versions is just that # list.versions is just that
if (list.versions) { if (list.versions) {
install <<- F install <<- F
......
...@@ -104,7 +104,7 @@ Packages are downloaded and installed from the repos given by the `repos` argume ...@@ -104,7 +104,7 @@ Packages are downloaded and installed from the repos given by the `repos` argume
The directory in which to install the package can be specified either by setting the `R_LIBS_USER` environment variable or with the `--lib` command line argument. The former is recommended and indeed required for running tests after installation (the testing system does not honor the `--lib` argument). The directory in which to install the package can be specified either by setting the `R_LIBS_USER` environment variable or with the `--lib` command line argument. The former is recommended and indeed required for running tests after installation (the testing system does not honor the `--lib` argument).
##### Specifying packages to Install ##### Specifying packages to Install
If the `--pkg-filelist` argument is provided then the associated file should contain a list of packages to install, one per line. Otherwise if a package pattern argument is given, then all packages matching the (R) regular expression are candidates for installation, otherwise all available packages are candidates, computed by invoking the `available.packages()` function. The candidate set can be adjusted with additional options. The `--use-installed-pkgs` option will cause `install.packages` to analyze the package installation directory for existing successfully installed packages and remove those from the candidate set. Some convenience options implicitly set `--pkg-filelist`, namely: If the `--pkg-filelist` argument is provided then the associated file should contain a list of packages to install, one per line. Otherwise if a package pattern argument is given, then all packages matching the (R) regular expression are candidates for installation, otherwise all available packages are candidates, computed by invoking the `available.packages()` function. The candidate set can be adjusted with additional options. The `--use-installed-pkgs` option will cause `install.packages` to analyze the package installation directory for existing successfully installed packages and remove those from the candidate set for installation. This option is implied by `--no-install`. Some convenience options implicitly set `--pkg-filelist`, namely:
--ok-only: sets it to the file `com.oracle.truffle.r.test.packages.ok.packages`. This file is a list of packages that are known to install. --ok-only: sets it to the file `com.oracle.truffle.r.test.packages.ok.packages`. This file is a list of packages that are known to install.
...@@ -143,7 +143,7 @@ Testing packages requires that they are first installed, so all of the above is ...@@ -143,7 +143,7 @@ Testing packages requires that they are first installed, so all of the above is
--verbose | -v: output tracing on basic steps --verbose | -v: output tracing on basic steps
-V: more verbose tracing -V: more verbose tracing
--dry-run: output what would be installed but don't actually install --dry-run: output what would be installed but don't actually install
--no-install | -n: suppress installation phase (useful for --create blacklist and --use-installed-pkgs/--run-tests) --no-install | -n: suppress installation phase (useful for --create blacklist and --run-tests)
--random count: install count packages randomly chosen from the candidate set --random count: install count packages randomly chosen from the candidate set
--testdir dir: store test output in dir (defaults to "test"). --testdir dir: store test output in dir (defaults to "test").
--print-ok-installs: print the successfully installed packages --print-ok-installs: print the successfully installed packages
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment