Skip to content

Commit 724deb9

Browse files
committed
Merge branch 'dev'
2 parents 1fadd5a + 3e8fd03 commit 724deb9

File tree

6 files changed

+82
-84
lines changed

6 files changed

+82
-84
lines changed

.travis.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
1-
language: c
1+
language: r
2+
sudo: required
23

34
env: NOT_CRAN="true"
45

5-
before_install:
6-
- curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh
7-
- chmod 755 ./travis-tool.sh
8-
- ./travis-tool.sh bootstrap
9-
10-
install:
11-
- ./travis-tool.sh install_deps
12-
13-
script: ./travis-tool.sh run_tests
14-
15-
on_failure:
16-
- ./travis-tool.sh dump_logs
17-
18-
after_script:
19-
- ./travis-tool.sh dump_logs
6+
r_binary_packages:
7+
- testthat
8+
- knitr
209

2110
branches:
2211
only:

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ Description: The goal of checkpoint is to solve the problem of package
1616
Immediately after completion of the rsync mirror process, the process takes a
1717
snapshot, thus creating the archive. Snapshot archives exist starting from
1818
2014-09-17.
19-
Version: 0.3.12
20-
Date: 2015-08-26
19+
Version: 0.3.13
20+
Date: 2015-09-01
2121
Author: Revolution Analytics
2222
Maintainer: Andrie de Vries <[email protected]>
2323
Copyright: Revolution Analytics

R/mranUrl.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ url <- function(url){
118118
if(getRversion() >= "3.2.0"){
119119
method <- switch(.Platform$OS.type,
120120
"unix" = if(libcurl()) "libcurl" else "default",
121-
"windows" = method <- "wininet",
121+
"windows" = "wininet",
122122
"default"
123123
)
124124
base::url(url, method = method)
@@ -128,6 +128,14 @@ url <- function(url){
128128
}
129129

130130
httpsSupported <- function(mran = "https://mran.revolutionanalytics.com/snapshot/"){
131+
tf <- tempfile()
132+
on.exit(unlink(tf))
133+
pdb <- suppressWarnings({
134+
tryCatch(download.file(url = paste0(mran, "PACKAGES"), destfile = tf,
135+
cacheOK = FALSE, quiet = TRUE,
136+
mode = "wb"), error = function(e)e)
137+
})
138+
if(inherits(pdb, "error")) return(FALSE)
131139
con <- suppressWarnings({
132140
tryCatch(url(mran),
133141
error = function(e)e)

tests/testthat/test-0-snapshots.R

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,27 @@ describe("is.404 works with http", {
7171
})
7272
})
7373

74-
if(httpsSupported()){
75-
describe("is.404 works with https", {
74+
describe("is.404 works with https", {
75+
76+
it("works on https", {
77+
if(!httpsSupported()) skip("https not supported")
78+
expect_true(is.404("https://mran.revolutionanalytics.com/snapshot/1972-01-01"))
79+
expect_false(is.404("https://mran.revolutionanalytics.com/snapshot"))
80+
expect_false(is.404("https://mran.revolutionanalytics.com/snapshot/2015-05-01"))
7681

77-
it("works on https", {
78-
expect_true(is.404("https://mran.revolutionanalytics.com/snapshot/1972-01-01"))
79-
expect_false(is.404("https://mran.revolutionanalytics.com/snapshot"))
80-
expect_false(is.404("https://mran.revolutionanalytics.com/snapshot/2015-05-01"))
81-
82-
})
8382
})
84-
} else {
85-
describe("is.404 gracefully deals with https URLs when https not supported", {
86-
87-
it("works on https", {
83+
})
84+
85+
describe("is.404 gracefully deals with https URLs when https not supported", {
86+
87+
it("works even when https is not supported", {
88+
with_mock(`checkpoint:::httpsSupported` = function(mran) FALSE, {
89+
# if(!httpsSupported()) skip("https not supported")
8890
expect_true(is.404("https://mran.revolutionanalytics.com/snapshot/1972-01-01"))
8991
expect_true(is.404("https://mran.revolutionanalytics.com/snapshot"))
9092
expect_true(is.404("https://mran.revolutionanalytics.com/snapshot/2015-05-01"))
91-
9293
})
94+
9395
})
94-
}
95-
96+
})
97+

tests/testthat/test-1-scan.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ describe("scanRepoPackages finds dependencies", {
66

77
collapse <- function(...) paste(..., sep="\n", collapse="\n")
88

9-
require("knitr", quietly = TRUE)
109

1110
foo <- function(token, insert){
1211
collapse(sprintf(token, insert))
@@ -37,7 +36,11 @@ describe("scanRepoPackages finds dependencies", {
3736
})
3837

3938
it("finds packages in Rmarkdown", {
40-
39+
if(!suppressWarnings(require("knitr", quietly = TRUE))){
40+
skip("knitr not available")
41+
}
42+
require("knitr", quietly = TRUE)
43+
4144
# Write dummy knitr code file to project
4245
knit <- sprintf("```{r}\n%s\n```", code)
4346
knitfile <- file.path(project_root, "knit.Rmd")

tests/testthat/test-2-checkpoint.R

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ test_checkpoint <- function(https = FALSE, snap.dates){
3535

3636
describe(paste("checkpoint -", url_prefix, "@", snap_date), {
3737

38-
39-
40-
packages.to.test = if(require("knitr"))
38+
packages.to.test = if(suppressWarnings(require("knitr", quietly = TRUE)))
4139
c(packages.to.test.base, packages.to.test.knitr) else
4240
packages.to.test.base
4341

@@ -88,62 +86,60 @@ test_checkpoint <- function(https = FALSE, snap.dates){
8886
))
8987
})
9088

91-
pdbMRAN <- available.packages(contriburl = contrib.url(repos = getSnapshotUrl(snap_date)))
92-
pdbLocal <- installed.packages(fields = "Date/Publication", noCache = TRUE)
93-
94-
pkgNames <- function(pdb)unname(pdb[, "Package"])
95-
96-
base.packages <- pkgNames(utils::installed.packages(priority = "base",
97-
lib.loc = .Library,
98-
noCache = TRUE))
99-
100-
pkgDepends <- function (pkg) {
101-
depMtrx <- tools:::getDepMtrx(pkg, instPkgs = pdbMRAN, local = FALSE)
102-
if (is.null(depMtrx)){
103-
stop(gettextf("package '%s' was not found", pkg), domain = NA)
104-
}
105-
tools::getDepList(depMtrx, pdbMRAN)
106-
}
107-
108-
packages.expected <- sort(unique(unlist(
109-
sapply(setdiff(packages.to.test, c("checkpoint", base.packages)), function(p){
110-
z <- pkgDepends(p)
111-
c(z$Depends, z$Imports)
112-
}, USE.NAMES = FALSE)
113-
)))
114-
115-
116-
expected.packages <- setdiff(packages.to.test, c("checkpoint", base.packages))
117-
11889
it("installs all packages correctly in local lib", {
90+
pdbMRAN <- available.packages(contriburl = contrib.url(repos = getSnapshotUrl(snap_date)))
91+
pdbLocal <- installed.packages(fields = "Date/Publication", noCache = TRUE)
92+
93+
pkgNames <- function(pdb)unname(pdb[, "Package"])
94+
95+
base.packages <- pkgNames(utils::installed.packages(priority = "base",
96+
lib.loc = .Library,
97+
noCache = TRUE))
98+
99+
pkgDepends <- function (pkg) {
100+
depMtrx <- tools:::getDepMtrx(pkg, instPkgs = pdbMRAN, local = FALSE)
101+
if (is.null(depMtrx)){
102+
stop(gettextf("package '%s' was not found", pkg), domain = NA)
103+
}
104+
tools::getDepList(depMtrx, pdbMRAN)
105+
}
106+
107+
packages.expected <- sort(unique(unlist(
108+
sapply(setdiff(packages.to.test, c("checkpoint", base.packages)), function(p){
109+
z <- pkgDepends(p)
110+
c(z$Depends, z$Imports)
111+
}, USE.NAMES = FALSE)
112+
)))
113+
114+
115+
expected.packages <- setdiff(packages.to.test, c("checkpoint", base.packages))
116+
119117
expect_true(
120118
all(expected.packages %in% pkgNames(pdbLocal))
121119
)
122-
})
123-
124-
messageMissingPackages <- function(exp, avail){
125-
if(!all(exp %in% avail)) {
126-
msg <- paste(
127-
"\n",
128-
paste0("Expected:", paste(exp, collapse = ", ")),
129-
paste0("Actual :", paste(avail, collapse = ", ")),
130-
paste0("Missing :", paste(setdiff(exp, avail), collapse = ", ")),
131-
"\n",
132-
sep = "\n")
133-
cat(msg)
120+
121+
messageMissingPackages <- function(exp, avail){
122+
if(!all(exp %in% avail)) {
123+
msg <- paste(
124+
"\n",
125+
paste0("Expected:", paste(exp, collapse = ", ")),
126+
paste0("Actual :", paste(avail, collapse = ", ")),
127+
paste0("Missing :", paste(setdiff(exp, avail), collapse = ", ")),
128+
"\n",
129+
sep = "\n")
130+
cat(msg)
131+
}
134132
}
135-
}
136-
messageMissingPackages(expected.packages, pkgNames(pdbLocal))
137-
138-
it("all packages have publication dates prior to checkpoint data", {
133+
messageMissingPackages(expected.packages, pkgNames(pdbLocal))
134+
139135
expect_true(
140136
all(
141137
na.omit(
142138
pdbLocal[, "Date/Publication"]) <=
143139
as.POSIXct(snap_date, tz="UTC"))
144140
)
141+
145142
})
146-
147143
# expect_true(
148144
# all(
149145
# sapply(setdiff(packages.to.test, "checkpoint"), function(x){
@@ -172,7 +168,7 @@ test_checkpoint <- function(https = FALSE, snap.dates){
172168
)
173169
})
174170
})
175-
171+
176172
# cleanup
177173
cleanCheckpointFolder(snap_date, checkpointLocation = checkpointLocation)
178174
}

0 commit comments

Comments
 (0)