Skip to content

Commit 0692b58

Browse files
TESTS: Assert that all backends record 'immediateCondition' as expected
1 parent b9c33d3 commit 0692b58

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: future
2-
Version: 1.49.0-9023
2+
Version: 1.49.0-9024
33
Title: Unified Parallel and Distributed Processing in R for Everyone
44
Depends:
55
R (>= 3.2.0)

R/backend_api-11.SequentialFutureBackend-class.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ nbrOfWorkers.SequentialFutureBackend <- function(evaluator) {
102102

103103

104104
#' @export
105+
106+
105107
nbrOfFreeWorkers.SequentialFutureBackend <- function(evaluator, background = FALSE, ...) {
106108
assert_no_positional_args_but_first()
107109
if (isTRUE(background)) 0L else 1L
@@ -117,9 +119,13 @@ getFutureBackendConfigs.UniprocessFuture <- function(future, ...) {
117119
immediateConditionHandlers = list(
118120
immediateCondition = local({
119121
prev <- NULL
120-
function(condition) {
121-
## Avoid re-catching itself
122-
if (identical(condition, prev)) return(FALSE)
122+
function(condition) {
123+
## Avoid re-catching and re-signaling itself
124+
if (identical(condition, prev)) {
125+
prev <<- NULL
126+
muffleCondition(condition)
127+
return(FALSE)
128+
}
123129
prev <<- condition
124130
## Resignal condition
125131
if (inherits(condition, "warning")) {

inst/testme/test-immediateCondition.R

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ for (ss in seq_along(strategies)) {
9090
stopifnot(length(msgs) == 0L)
9191
}
9292
})
93-
93+
9494
message("- checking if resolved")
9595
msgs <- recordMessages({
9696
r <- resolved(f)
@@ -140,7 +140,23 @@ for (ss in seq_along(strategies)) {
140140
stopifnot(identical(msgs, c("IM1\n", "IW", "IM2\n", "M\n")))
141141
}
142142
})
143-
143+
144+
r <- result(f)
145+
conditions <- r$conditions
146+
if (length(conditions) != 4L) {
147+
str(conditions)
148+
stopifnot(length(conditions) == 4L)
149+
}
150+
conditions <- lapply(conditions, FUN = .subset2, "condition")
151+
str(conditions)
152+
stopifnot(length(conditions) == 4L)
153+
stopifnot(
154+
vapply(conditions, FUN.VALUE = FALSE, FUN = inherits, "condition"),
155+
vapply(conditions[c(1,3,4)], FUN.VALUE = FALSE, FUN = inherits, "immediateCondition"),
156+
vapply(conditions[c(1,2,4)], FUN.VALUE = FALSE, FUN = inherits, "message"),
157+
vapply(conditions[c(3)], FUN.VALUE = FALSE, FUN = inherits, "warning")
158+
)
159+
144160
message("- getting value again")
145161
msgs <- recordMessages({
146162
v <- value(f)
@@ -270,4 +286,3 @@ for (ss in seq_along(strategies)) {
270286
} ## for (ss ...)
271287

272288
message("*** immediateCondition:s ... DONE")
273-

0 commit comments

Comments
 (0)