Skip to content

Commit

Permalink
Updated parallel tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley committed Apr 20, 2015
1 parent 23bba54 commit 79a6b0e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
6 changes: 5 additions & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## Changes

This is a minor update. It includes:
This is a resubmission: it fixes the failure for tests to complete on 32-bit windows. (I accidentally included tests that need an interactive environment, which I run locally.)

----

The initial submission included:

* Fixes for R CMD check notes.

Expand Down
39 changes: 23 additions & 16 deletions tests/testthat/test-parallel.r
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@
context("Parallel")

if (require("doParallel", quietly = TRUE)) {
registerDoParallel(cores = 2)
with_parallel <- function(code) {
skip_on_cran()
skip_if_not_installed("doParallel")

test_that("l_ply respects .parallel", {
skip_on_cran()
doParallel::registerDoParallel(cores = 2)
on.exit(doParallel::stopImplicitCluster())
code
}

test_that("l_ply respects .parallel", {
with_parallel(
expect_that(
l_ply(c(0.1, 0.1), Sys.sleep, .parallel = TRUE),
takes_less_than(0.18))
})
)
})

test_that("l_ply + .parallel complains about invalid arguments", {
test_that("l_ply + .parallel complains about invalid arguments", {
with_parallel({
expect_message(
l_ply(1:10, force, .parallel = TRUE, .print = TRUE),
"Printing disabled")
expect_message(
l_ply(1:10, force, .parallel = TRUE, .progress = "text"),
"Progress disabled")
})
})

test_that("llply + .parallel complains about invalid arguments", {
test_that("llply + .parallel complains about invalid arguments", {
with_parallel({
expect_message(
llply(1:10, force, .parallel = TRUE, .progress = "text"),
"Progress disabled")
})
})

test_that(".paropts passes options to foreach", {
combine <- function(a, b) NULL
x <- llply(1:10, identity, .parallel = TRUE,
.paropts = list(.combine = combine))
expect_equal(x, NULL)
})

registerDoParallel(1)
}
test_that(".paropts passes options to foreach", {
combine <- function(a, b) NULL
with_parallel(x <- llply(1:10, identity, .parallel = TRUE,
.paropts = list(.combine = combine)))
expect_equal(x, NULL)
})

0 comments on commit 79a6b0e

Please sign in to comment.