Skip to content

Commit

Permalink
Skip more tests on CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Sep 15, 2022
1 parent 423bee2 commit 6e0600c
Show file tree
Hide file tree
Showing 27 changed files with 292 additions and 27 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# targets 0.13.4

* Implement custom alternative to `skip_on_cran()` to avoid https://github.com/r-lib/testthat/issues/1470#issuecomment-1248145555.
* Skip more tests on CRAN.

# targets 0.13.3

Expand Down
23 changes: 23 additions & 0 deletions tests/testthat/test-class_builder.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ tar_test("target_run() on a good builder", {
})

tar_test("target_run() on a errored builder", {
skip_cran()
tar_option_set(envir = tmpenv())
local_init(pipeline_init())$start()
x <- target_init(name = "abc", expr = quote(identity(identity(stop(123)))))
Expand All @@ -37,6 +38,7 @@ tar_test("target_run() on a errored builder", {
})

tar_test("target_run_worker()", {
skip_cran()
local_init(pipeline_init())$start()
x <- target_init(name = "abc", expr = quote(identity(identity(stop(123)))))
y <- target_run_worker(
Expand Down Expand Up @@ -84,6 +86,7 @@ tar_test("read and write objects", {
})

tar_test("error = \"stop\" means stop on error", {
skip_cran()
x <- target_init("x", expr = quote(stop(123)), error = "stop")
y <- target_init("y", expr = quote(stop(456)), error = "stop")
pipeline <- pipeline_init(list(x, y))
Expand All @@ -96,6 +99,7 @@ tar_test("error = \"stop\" means stop on error", {
})

tar_test("error = \"continue\" means continue on error", {
skip_cran()
x <- target_init("x", expr = quote(stop(123)), error = "continue")
y <- target_init("y", expr = quote(stop(456)), error = "continue")
pipeline <- pipeline_init(list(x, y))
Expand All @@ -114,6 +118,7 @@ tar_test("error = \"continue\" means continue on error", {
})

tar_test("error = \"abridge\" means do not schedule new targets", {
skip_cran()
x <- target_init("x", expr = quote(stop(123)), error = "abridge")
y <- target_init("y", expr = quote(x))
pipeline <- pipeline_init(list(x, y))
Expand All @@ -125,6 +130,7 @@ tar_test("error = \"abridge\" means do not schedule new targets", {
})

tar_test("errored targets are not up to date", {
skip_cran()
x <- target_init("x", expr = quote(123))
pipeline <- pipeline_init(list(x))
local_init(pipeline)$run()
Expand All @@ -139,6 +145,7 @@ tar_test("errored targets are not up to date", {
})

tar_test("same if we continue on error", {
skip_cran()
x <- target_init("x", expr = quote(123))
pipeline <- pipeline_init(list(x))
local_init(pipeline)$run()
Expand All @@ -154,6 +161,7 @@ tar_test("same if we continue on error", {
})

tar_test("builder writing from main", {
skip_cran()
tar_option_set(envir = tmpenv(a = "123"))
local_init(pipeline_init())$start()
x <- target_init("abc", expr = quote(a), format = "rds", storage = "main")
Expand All @@ -174,6 +182,7 @@ tar_test("builder writing from main", {
})

tar_test("builder writing from worker", {
skip_cran()
tar_option_set(envir = tmpenv(a = "123"))
local_init(pipeline_init())$start()
x <- target_init(
Expand All @@ -198,6 +207,7 @@ tar_test("builder writing from worker", {
})

tar_test("retrieval = \"none\"", {
skip_cran()
skip_cran()
tar_script({
list(
Expand All @@ -218,6 +228,7 @@ tar_test("storage = \"none\" errors if user does not write storage", {
})

tar_test("storage = \"none\" ignores return value but tracks file", {
skip_cran()
tar_script({
run_x <- function() {
if (!file.exists("_targets/objects")) {
Expand Down Expand Up @@ -276,6 +287,7 @@ tar_test("storage = \"none\" ignores return value but tracks file", {
})

tar_test("dynamic file writing from main", {
skip_cran()
local_init(pipeline_init())$start()
envir <- new.env(parent = environment())
tar_option_set(envir = envir)
Expand All @@ -301,6 +313,7 @@ tar_test("dynamic file writing from main", {
})

tar_test("dynamic file has illegal path", {
skip_cran()
x <- target_init(
name = "abc",
expr = quote("a*b"),
Expand All @@ -311,6 +324,7 @@ tar_test("dynamic file has illegal path", {
})

tar_test("dynamic file has empty path", {
skip_cran()
x <- target_init(
name = "abc",
expr = quote(NULL),
Expand All @@ -321,6 +335,7 @@ tar_test("dynamic file has empty path", {
})

tar_test("dynamic file has missing path value", {
skip_cran()
x <- target_init(
name = "abc",
expr = quote(NA_character_),
Expand All @@ -331,6 +346,7 @@ tar_test("dynamic file has missing path value", {
})

tar_test("dynamic file is missing at path", {
skip_cran()
x <- target_init(
name = "abc",
expr = quote("nope"),
Expand All @@ -342,6 +358,7 @@ tar_test("dynamic file is missing at path", {
})

tar_test("dynamic file writing from worker", {
skip_cran()
local_init(pipeline_init())$start()
envir <- new.env(parent = environment())
tar_option_set(envir = envir)
Expand Down Expand Up @@ -369,6 +386,7 @@ tar_test("dynamic file writing from worker", {
})

tar_test("value kept if storage is local", {
skip_cran()
local_init(pipeline_init())$start()
envir <- new.env(parent = environment())
tar_option_set(envir = envir)
Expand Down Expand Up @@ -417,6 +435,7 @@ tar_test("basic progress responses are correct", {
})

tar_test("builders load their packages", {
skip_cran()
x <- target_init(
"x",
quote(tibble(x = "x")),
Expand All @@ -432,6 +451,7 @@ tar_test("builders load their packages", {
})

tar_test("relay errors as messages if error is continue", {
skip_cran()
tar_script({
tar_option_set(error = "continue")
list(
Expand All @@ -453,13 +473,15 @@ tar_test("relay errors as messages if error is continue", {
})

tar_test("target_needs_worker(builder)", {
skip_cran()
x <- tar_target(y, rep(x, 2), deployment = "worker")
expect_true(target_needs_worker(x))
x <- tar_target(y, rep(x, 2), deployment = "main")
expect_false(target_needs_worker(x))
})

tar_test("bootstrap builder for shortcut", {
skip_cran()
tar_script({
list(
tar_target(w, 1L),
Expand Down Expand Up @@ -503,6 +525,7 @@ tar_test("informative error when bootstrap fails", {
})

tar_test("validate with nonmissing file and value", {
skip_cran()
x <- target_init(name = "abc", expr = quote(1L + 1L))
x$value <- value_init(123)
file <- x$store$file
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-class_clustermq.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tar_test("clustermq$workers", {
})

tar_test("workerless deployment works", {
skip_cran()
skip_on_os("windows")
skip_on_os("solaris")
require_clustermq()
Expand All @@ -29,6 +30,7 @@ tar_test("workerless deployment works", {
})

tar_test("semi-workerless deployment works", {
skip_cran()
skip_on_os("windows")
skip_on_os("solaris")
require_clustermq()
Expand Down Expand Up @@ -58,6 +60,7 @@ tar_test("semi-workerless deployment works", {
})

tar_test("some targets up to date, some not", {
skip_cran()
skip_on_os("windows")
skip_on_os("solaris")
require_clustermq()
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-class_future.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ tar_test("future$workers", {
})

tar_test("workerless deployment works", {
skip_cran()
skip_if_not_installed("future")
tar_runtime$set_fun("tar_make_future")
on.exit(tar_runtime$unset_fun())
Expand All @@ -26,6 +27,7 @@ tar_test("workerless deployment works", {
})

tar_test("semi-workerless deployment works", {
skip_cran()
skip_if_not_installed("future")
tar_runtime$set_fun("tar_make_future")
on.exit(tar_runtime$unset_fun())
Expand All @@ -48,6 +50,7 @@ tar_test("semi-workerless deployment works", {
})

tar_test("some targets up to date, some not", {
skip_cran()
skip_if_not_installed("future")
tar_runtime$set_fun("tar_make_future")
on.exit(tar_runtime$unset_fun())
Expand All @@ -69,6 +72,7 @@ tar_test("some targets up to date, some not", {
})

tar_test("specialized plans (unstructured resources)", {
skip_cran()
skip_if_not_installed("future")
tar_runtime$set_fun("tar_make_future")
on.exit(tar_runtime$unset_fun())
Expand Down Expand Up @@ -188,6 +192,7 @@ tar_test("branching plan", {
})

tar_test("future_value_target() produces target objects", {
skip_cran()
tar_runtime$set_fun("tar_make_future")
on.exit(tar_runtime$unset_fun())
pipeline <- pipeline_init(list(tar_target(x, 1)))
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-class_keras.R
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
tar_test("validate keras format", {
skip_cran()
skip_if_not_installed("keras")
x <- target_init(name = "abc", expr = quote(f()), format = "keras")
expect_silent(target_validate(x))
})

tar_test("keras packages", {
skip_cran()
x <- tar_target(x, 1, format = "keras")
out <- store_get_packages(x$store)
expect_equal(out, "keras")
})

tar_test("does not inherit from tar_external", {
skip_cran()
store <- tar_target(x, "x_value", format = "keras")$store
expect_false(inherits(store, "tar_external"))
})

tar_test("store_row_path()", {
skip_cran()
store <- tar_target(x, "x_value", format = "keras")$store
store$file$path <- "path"
expect_equal(store_row_path(store), NA_character_)
})

tar_test("store_path_from_record()", {
skip_cran()
store <- tar_target(x, "x_value", format = "keras")$store
record <- record_init(name = "x", path = "path", format = "keras")
expect_equal(
Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/test-class_outdated.R
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
tar_test("outdated$outdated", {
skip_cran()
out <- outdated_init(pipeline_init())
expect_silent(counter_validate(out$outdated))
})

tar_test("outdated$is_outdated()", {
skip_cran()
out <- outdated_init(pipeline_init(), reporter = "silent")
expect_equal(out$is_outdated("x"), FALSE)
})

tar_test("outdated$register_outdated()", {
skip_cran()
out <- outdated_init(pipeline_init(), reporter = "silent")
out$register_outdated("x")
expect_equal(out$is_outdated("x"), TRUE)
})

tar_test("counter_validate(outdated)", {
skip_cran()
out <- outdated_init(pipeline_init(), reporter = "silent")
expect_silent(counter_validate(out$outdated))
})

tar_test("full non-branching run", {
skip_cran()
out <- outdated_init(pipeline_order(), reporter = "silent")
out$run()
exp <- sort(pipeline_get_names(pipeline_order()))
Expand All @@ -32,6 +37,7 @@ tar_test("full non-branching run", {
})

tar_test("full branching run with forecast reporter", {
skip_cran()
out <- outdated_init(
pipeline_map(),
queue = "sequential",
Expand All @@ -52,6 +58,7 @@ tar_test("full branching run with forecast reporter", {
})

tar_test("Outdated is idempotent (no overwriting imports)", {
skip_cran()
envir <- new.env(parent = baseenv())
envir$f <- function(x) x
tar_option_set(envir = envir)
Expand All @@ -71,6 +78,7 @@ tar_test("Outdated is idempotent (no overwriting imports)", {
})

tar_test("Update the command of a stem", {
skip_cran()
x <- target_init("x", quote(seq_len(3)))
y <- target_init("y", quote(x), pattern = quote(map(x)))
z <- target_init("z", quote(y), pattern = quote(map(y)))
Expand All @@ -92,6 +100,7 @@ tar_test("Update the command of a stem", {
})

tar_test("Update the file of a branch", {
skip_cran()
x <- target_init("x", quote(seq_len(3)))
y <- target_init("y", quote(x), pattern = quote(map(x)))
z <- target_init("z", quote(y), pattern = quote(map(y)))
Expand Down Expand Up @@ -119,6 +128,7 @@ tar_test("Update the file of a branch", {
})

tar_test("Update the file of a branch and aggregate", {
skip_cran()
x <- target_init("x", quote(seq_len(3)))
y <- target_init("y", quote(x), pattern = quote(map(x)))
z <- target_init("z", quote(y))
Expand All @@ -145,6 +155,7 @@ tar_test("Update the file of a branch and aggregate", {
})

tar_test("Corrupt a branch", {
skip_cran()
x <- target_init("x", quote(seq_len(3)))
y <- target_init("y", quote(x), pattern = quote(map(x)))
z <- target_init("z", quote(y), pattern = quote(map(y)))
Expand All @@ -169,6 +180,7 @@ tar_test("Corrupt a branch", {
})

tar_test("Corrupt a branch but turn off the depend cue", {
skip_cran()
x <- target_init("x", quote(seq_len(3)))
y <- target_init("y", quote(x), pattern = quote(map(x)))
z <- target_init("z", quote(y), pattern = quote(map(y)))
Expand All @@ -195,6 +207,7 @@ tar_test("Corrupt a branch but turn off the depend cue", {
})

tar_test("Depend on all branches", {
skip_cran()
x <- target_init("x", quote(seq_len(3)))
y <- target_init("y", quote(x), pattern = quote(map(x)))
z <- target_init("z", quote(y))
Expand All @@ -218,6 +231,7 @@ tar_test("Depend on all branches", {
})

tar_test("map over a stem with no branches previously", {
skip_cran()
pipeline <- pipeline_init(
list(
target_init("x", quote(seq_len(2))),
Expand Down
Loading

0 comments on commit 6e0600c

Please sign in to comment.