Skip to content

Commit 2d3f4bc

Browse files
TESTS: Skip plan(..., workers = <...>) tests if plan tested has already set 'workers'
1 parent a8b7fb4 commit 2d3f4bc

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: future.tests
22
Title: Test Suite for 'Future API' Backends
3-
Version: 0.9.0-9012
3+
Version: 0.9.0-9013
44
Authors@R: c(
55
person("Henrik", "Bengtsson", role = c("aut", "cre", "cph"), email = "[email protected]"),
66
person(family = "The R Consortium", comment = "Project was awarded an Infrastructure Steering Committee (ISC) grant in 2017", role = "fnd"))

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
that is about to be deprecated in the **future** package.
1919

2020
* Relax assertions in test of `resolved()` with lazy futures.
21+
22+
## Bug Fixes
23+
24+
* Tests on `plan()` adjusting argument `workers` were not skipped if
25+
the plan tested already sets argument `workers` to a fixed value,
26+
e.g. `plan(cluster, workers = cl)`.
2127

2228

2329
# Version 0.9.0 [2025-04-14]

inst/test-db/plan.R

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,14 @@ make_test(title = "plan() - workers=<numeric>", args = list(), tags = c("plan",
1212
future.tests::skip_test()
1313
return()
1414
}
15-
15+
16+
## Is argument 'workers' already set?
17+
current_tweaks <- attr(current_plan, "tweaks", exact = TRUE)
18+
if ("workers" %in% names(current_tweaks)) {
19+
future.tests::skip_test()
20+
return()
21+
}
22+
1623
## FIXME: These tests only work for backends where 'workers' take
1724
## numeric values.
1825
plan(current_plan, workers = 1L)
@@ -41,7 +48,14 @@ make_test(title = "plan() - workers=<function>", args = list(), tags = c("plan",
4148
future.tests::skip_test()
4249
return()
4350
}
44-
51+
52+
## Is argument 'workers' already set?
53+
current_tweaks <- attr(current_plan, "tweaks", exact = TRUE)
54+
if ("workers" %in% names(current_tweaks)) {
55+
future.tests::skip_test()
56+
return()
57+
}
58+
4559
n0 <- nbrOfWorkers()
4660
cat(sprintf("Number of initial workers: %g\n", n0))
4761

@@ -83,7 +97,14 @@ make_test(title = "plan() - workers=<invalid>", args = list(), tags = c("plan",
8397
future.tests::skip_test()
8498
return()
8599
}
86-
100+
101+
## Is argument 'workers' already set?
102+
current_tweaks <- attr(current_plan, "tweaks", exact = TRUE)
103+
if ("workers" %in% names(current_tweaks)) {
104+
future.tests::skip_test()
105+
return()
106+
}
107+
87108
## Invalid number of workers or value on 'workers'
88109
res <- tryCatch({
89110
plan(current_plan, workers = 0L)

0 commit comments

Comments
 (0)