Skip to content

Commit

Permalink
TESTS: Adjust tests accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Feb 8, 2025
1 parent 2189b67 commit 432f266
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 44 deletions.
42 changes: 9 additions & 33 deletions tests/futureCall.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,10 @@ for (cores in 1:availCores) {
if (globals) {
stopifnot(all.equal(v1, v0))
} else {
if (!lazy && strategy %in% c("sequential", "multicore")) {
stopifnot(all.equal(v1, v0))
} else {
stopifnot(inherits(res1, "error"))
}
stopifnot(inherits(res1, "error"))
}
} else {
if (!inherits(res1, "error")) {
utils::str(list(strategy = strategy, globals = globals, lazy = lazy, v0 = v0, v1 = v1))
stopifnot(all.equal(v1, v0))
} else {
stopifnot(!globals)
Expand All @@ -93,14 +88,9 @@ for (cores in 1:availCores) {
utils::str(list(strategy = strategy, globals = globals, lazy = lazy, v0 = v0, res2 = res2))
if (isTRUE(as.logical(Sys.getenv("R_CHECK_IDEAL")))) {
message("R_CHECK_IDEAL=TRUE")
if (globals) {
stopifnot(all.equal(v2, v0))
} else {
stopifnot(all.equal(v2, v0))
}
stopifnot(all.equal(v2, v0))
} else {
if (!inherits(res2, "error")) {
utils::str(list(strategy = strategy, globals = globals, lazy = lazy, v0 = v0, v2 = v2))
stopifnot(all.equal(v2, v0))
} else {
stopifnot(!globals)
Expand All @@ -120,14 +110,9 @@ for (cores in 1:availCores) {
utils::str(list(strategy = strategy, globals = globals, lazy = lazy, v0 = v0, res3 = res3))
if (isTRUE(as.logical(Sys.getenv("R_CHECK_IDEAL")))) {
message("R_CHECK_IDEAL=TRUE")
if (globals) {
stopifnot(all.equal(v3, v0))
} else {
stopifnot(all.equal(v3, v0))
}
stopifnot(all.equal(v3, v0))
} else {
if (!inherits(res3, "error")) {
utils::str(list(strategy = strategy, globals = globals, lazy = lazy, v0 = v0, v3 = v3, res3 = res3))
stopifnot(all.equal(v3, v0))
} else {
stopifnot(!globals)
Expand Down Expand Up @@ -163,10 +148,12 @@ for (cores in 1:availCores) {
message("future.globals.globalsOf.locals=TRUE")
if (globals) {
stopifnot(identical(v4, truth))
} else if (lazy) {
stopifnot(inherits(v4, "error"))
} else {
stopifnot(identical(v4, truth))
if (lazy) {
stopifnot(inherits(v4, "error"))
} else {
stopifnot(identical(v4, truth))
}
}
} else {
message("future.globals.globalsOf.locals=FALSE")
Expand All @@ -182,23 +169,12 @@ for (cores in 1:availCores) {
message("future.globals.globalsOf.locals=TRUE")
if (globals) {
stopifnot(identical(v4, truth))
} else if (lazy) {
stopifnot(inherits(v4, "error"))
} else if (strategy %in% c("sequential", "multicore")) {
stopifnot(inherits(v4, "error"))
} else {
stopifnot(inherits(v4, "error"))
}
} else {
message("future.globals.globalsOf.locals=FALSE")
if (strategy %in% c("sequential", "multicore")) {
stopifnot(inherits(v4, "error"))
} else if (lazy) {
stopifnot(inherits(v4, "error"))
} else {
stopifnot(inherits(v4, "error"))
# stopifnot(identical(v4, truth))
}
stopifnot(inherits(v4, "error"))
}
}
})
Expand Down
14 changes: 3 additions & 11 deletions tests/globals,locals.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ for (strategy in supportedStrategies()) {
if (isTRUE(getOption("future.globals.globalsOf.locals", TRUE))) {
message("future.globals.globalsOf.locals=TRUE")
if (strategy %in% c("sequential", "multicore")) {
stopifnot(inherits(res, "error"))
stopifnot(identical(v, truth))
} else {
stopifnot(identical(v, truth))
}
Expand Down Expand Up @@ -145,18 +145,10 @@ for (strategy in supportedStrategies()) {
message("future.globals.keepWhere=FALSE")
if (isTRUE(getOption("future.globals.globalsOf.locals", TRUE))) {
message("future.globals.globalsOf.locals=TRUE")
if (strategy %in% c("sequential", "multicore")) {
stopifnot(identical(v, 4)) ## <= SERIOUS BUG!
} else {
stopifnot(identical(v, 4)) ## <= SERIOUS BUG!
}
stopifnot(identical(v, 4)) ## <= SERIOUS BUG!
} else {
message("future.globals.globalsOf.locals=FALSE")
if (strategy %in% c("sequential", "multicore")) {
stopifnot(inherits(v, "error"))
} else {
stopifnot(identical(v, truth))
}
stopifnot(inherits(v, "error"))
}
}
} ## for (strategy ...)
Expand Down

0 comments on commit 432f266

Please sign in to comment.