From afa4865b409e656330b9806d7676c565ae2e84e3 Mon Sep 17 00:00:00 2001 From: Alex Chubaty Date: Mon, 17 Nov 2014 18:44:06 -0800 Subject: [PATCH] fixed test_all errors (#25, #28, #29) added missing repos as needed --- R/addPackages.R | 3 ++- R/updatePackages.R | 2 +- tests/testthat/test-5-addOldPackage.R | 12 ++++++++---- tests/testthat/test-6-checkVersions.R | 3 ++- tests/testthat/test-7-updatePackages.R | 3 ++- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/R/addPackages.R b/R/addPackages.R index aba3f6c..d1becaf 100644 --- a/R/addPackages.R +++ b/R/addPackages.R @@ -236,7 +236,8 @@ addOldPackage <- function(pkgs=NULL, path=NULL, vers=NULL, pkgPath <- file.path(path=path, repoPrefix(type, R.version)) if(!file.exists(pkgPath)) dir.create(pkgPath, recursive=TRUE) sapply(oldPkgs, function(x) { - download.file(x, destfile=file.path(pkgPath, basename(x))) + result <- download.file(x, destfile=file.path(pkgPath, basename(x)), method="auto") + if(result!=0) warning("error downloading file ", x) }) if (writePACKAGES) tools::write_PACKAGES(dir=pkgPath, type=type) } diff --git a/R/updatePackages.R b/R/updatePackages.R index 53bfbcc..9e5bf10 100644 --- a/R/updatePackages.R +++ b/R/updatePackages.R @@ -194,6 +194,6 @@ updatePackages <- function (path=NULL, repos=getOption("repos"), oldPkgs } if (length(update[,"Package"])) { - addPackage(update[,"Package"], path=path, type=type) + addPackage(update[,"Package"], path=path, repos=repos, type=type) } } diff --git a/tests/testthat/test-5-addOldPackage.R b/tests/testthat/test-5-addOldPackage.R index 0b0738c..3b149e1 100644 --- a/tests/testthat/test-5-addOldPackage.R +++ b/tests/testthat/test-5-addOldPackage.R @@ -34,7 +34,8 @@ test_that("addOldPackage downloads source files and builds PACKAGES file", { oldVers <- data.frame(package=c("foreach", "codetools", "iterators"), version=c("1.4.0", "0.2-7", "1.0.5"), stringsAsFactors=FALSE) - addOldPackage(pkgList, path=repo_root, vers=oldVers[,"version"], type=pkg_type) + addOldPackage(pkgList, path=repo_root, vers=oldVers[,"version"], + repos=revolution, type=pkg_type) dlVers <- miniCRAN:::getPkgVersFromFile(list.files(file.path(repo_root, prefix))) @@ -69,7 +70,8 @@ test_that("addOldPackage downloads windows binary files and builds PACKAGES file stringsAsFactors=FALSE) expect_error( - addOldPackage(pkgList, path=repo_root, vers=oldVers[,"version"], type=pkg_type) + addOldPackage(pkgList, path=repo_root, vers=oldVers[,"version"], + repos=revolution, type=pkg_type) ) unlink(repo_root, recursive=TRUE) @@ -94,7 +96,8 @@ test_that("addOldPackage downloads mac binary files and builds PACKAGES file", { version=c("1.4.0", "0.2-7", "1.0.5")) expect_error( - addOldPackage(pkgList, path=repo_root, vers=oldVers[,"version"], type=pkg_type) + addOldPackage(pkgList, path=repo_root, vers=oldVers[,"version"], + repos=revolution, type=pkg_type) ) unlink(repo_root, recursive=TRUE) @@ -118,7 +121,8 @@ test_that("addOldPackage downloads mac binary files and builds PACKAGES file", { # stringsAsFactors=FALSE) # # expect_error( -# addOldPackage(pkgList, path=repo_root, vers=oldVers[,"version"], type=pkg_type) +# addOldPackage(pkgList, path=repo_root, vers=oldVers[,"version"], +# repos=revolution, type=pkg_type) # ) # # unlink(repo_root, recursive=TRUE) diff --git a/tests/testthat/test-6-checkVersions.R b/tests/testthat/test-6-checkVersions.R index 087461a..a56a71e 100644 --- a/tests/testthat/test-6-checkVersions.R +++ b/tests/testthat/test-6-checkVersions.R @@ -33,7 +33,8 @@ test_that("checkVersions downloads old and current source files checks for these oldVers <- data.frame(package=c("foreach", "codetools", "iterators"), version=c("1.4.0", "0.2-7", "1.0.5"), stringsAsFactors=FALSE) - addOldPackage(pkgList, path=repo_root, vers=oldVers[,"version"], type=pkg_type) + addOldPackage(pkgList, path=repo_root, vers=oldVers[,"version"], + repos=revolution, type=pkg_type) makeRepo(pkgList, path=repo_root, repos=revolution, type=pkg_type, writePACKAGES=FALSE) files <- suppressWarnings(checkVersions(pkgList, path=repo_root, type=pkg_type)) diff --git a/tests/testthat/test-7-updatePackages.R b/tests/testthat/test-7-updatePackages.R index 602da47..bfc07ea 100644 --- a/tests/testthat/test-7-updatePackages.R +++ b/tests/testthat/test-7-updatePackages.R @@ -34,7 +34,8 @@ test_that("updatePackages downloads source files and builds PACKAGES file", { oldVers <- data.frame(package=c("foreach", "codetools", "iterators"), version=c("1.4.0", "0.2-7", "1.0.5"), stringsAsFactors=FALSE) - addOldPackage(pkgList, path=repo_root, vers=oldVers[,"version"], type=pkg_type) + addOldPackage(pkgList, path=repo_root, vers=oldVers[,"version"], + repos=revolution, type=pkg_type) suppressWarnings(updatePackages(path=repo_root, repos=revolution, type=pkg_type, ask=FALSE)) updateVers <- miniCRAN:::getPkgVersFromFile(list.files(file.path(repo_root, prefix)))