Skip to content

Commit 7f665fa

Browse files
Add test for makeClusterSequential() cluster futures
1 parent 8278ef2 commit 7f665fa

File tree

3 files changed

+36
-34
lines changed

3 files changed

+36
-34
lines changed

NEWS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
deprecation warnings. Deprecated also hidden argument `local`,
4444
which was kept around for legacy reasons.
4545

46-
* Use of `plan(..., earlySignal = ...)` is now defunct and produces a
47-
deprecation warning.
46+
* Use of `plan(..., earlySignal = ...)` is now deprecated and
47+
produces a deprecation warning.
4848

4949
* Remove argument `run` from `resolved()`. Attempts to set it
5050
produces a deprecation warning.

inst/testme/run.R

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,34 @@
1313
#' inst/testme/run.R <test-name.R>
1414
#'
1515
#' Options:
16-
#' --package=<pkg> The name of the package being tested
17-
#' (Environment variable: `R_TESTME_PACKAGE`)
18-
#' (Default: The `Package` field of the DESCRIPTION file)
19-
#' --name=<name> The name of the test to run, used to locate the test
20-
#' script `test-<name>.R`
21-
#' (Environment variable: `R_TESTME_NAME`)
22-
#' --not-cran Set environment variable `NOT_CRAN=true`
23-
#' --covr=summary Estimate test code coverage with basic summary
24-
#' --covr=tally Estimate test code coverage with full tally summary
25-
#' --covr=report Estimate test code coverage with full HTML report
26-
#' --debug Output debug messages
27-
#' (Environment variable: `R_TESTME_DEBUG`)
16+
#' --package=<pkg> The name of the package being tested
17+
#' (Environment variable: `R_TESTME_PACKAGE`)
18+
#' (Default: The `Package` field of the DESCRIPTION file)
19+
#' --name=<name> The name of the test to run, used to locate the test
20+
#' script `test-<name>.R`
21+
#' (Environment variable: `R_TESTME_NAME`)
22+
#' --not-cran Set environment variable `NOT_CRAN=true`
23+
#' --coverage=summary Estimate test code coverage with basic summary
24+
#' --coverage=tally Estimate test code coverage with full tally summary
25+
#' --coverage=report Estimate test code coverage with full HTML report
26+
#' --debug Output debug messages
27+
#' (Environment variable: `R_TESTME_DEBUG`)
2828
#'
2929
#' Examples:
3030
#' testme/test-abc.R
3131
#' testme/test-abc.R --not-cran
32-
#' tests/test-cpuLoad.R --covr=report
32+
#' tests/test-cpuLoad.R --coverage=report
3333
#'
3434
#' inst/testme/run.R inst/testme/test-abc.R
35-
#' inst/testme/run.R inst/testme/test-abc.R --covr
35+
#' inst/testme/run.R inst/testme/test-abc.R --coverage
3636
#'
3737
#' Environment variables:
3838
#' * R_TESTME_PACKAGE
3939
#' * R_TESTME_NAME
4040
#' * R_TESTME_PATH
4141
#' * R_TESTME_FILTER_NAME
4242
#' * R_TESTME_FILTER_TAGS
43-
#' * R_TESTME_COVR
43+
#' * R_TESTME_COVERAGE
4444
#' * R_TESTME_DEBUG
4545
main <- function() {
4646
cmd_args <- commandArgs(trailingOnly = TRUE)
@@ -99,26 +99,21 @@ main <- function() {
9999
Sys.setenv(R_TESTME_DEBUG = "TRUE")
100100
}
101101

102-
pattern <- "^--covr(|=([[:alpha:][:alnum:]]+))$"
102+
pattern <- "^--coverage(|=([[:alpha:][:alnum:]]+))$"
103103
idx <- grep(pattern, cmd_args)
104104
if (length(idx) > 0L) {
105105
value <- gsub(pattern, "\\2", cmd_args[idx])
106106
if (!nzchar(value)) {
107-
covr <- "summary"
107+
coverage <- "summary"
108108
} else {
109-
covr <- match.arg(value, choices = c("summary", "tally", "report"))
109+
coverage <- match.arg(value, choices = c("none", "summary", "tally", "report"))
110110
}
111111
cmd_args <- cmd_args[-idx]
112112
} else {
113-
value <- Sys.getenv("R_TESTME_COVR", "FALSE")
114-
if (toupper(value) %in% c("FALSE", "TRUE")) {
115-
value <- as.logical(value)
116-
covr <- if (value) "summary" else "none"
117-
} else {
118-
covr <- match.arg(value, choices = c("summary", "tally", "report"))
119-
}
113+
value <- Sys.getenv("R_TESTME_COVERAGE", "none")
114+
coverage <- match.arg(value, choices = c("none", "summary", "tally", "report"))
120115
}
121-
if (covr != "none") {
116+
if (coverage != "none") {
122117
if (!utils::file_test("-f", "DESCRIPTION")) {
123118
stop("Current folder does not look like a package folder")
124119
}
@@ -179,7 +174,9 @@ main <- function() {
179174
}
180175

181176
debug <- isTRUE(as.logical(Sys.getenv("R_TESTME_DEBUG")))
182-
177+
178+
coverage <- match.arg(coverage, choices = c("none", "summary", "tally", "report"))
179+
183180
## Create 'testme' environment on the search() path
184181
testme_config <- list(
185182
testme = TRUE,
@@ -191,14 +188,14 @@ main <- function() {
191188
script = testme_file,
192189
path = path,
193190
on_cran = on_cran(),
194-
covr = covr,
191+
coverage = coverage,
195192
debug = debug
196193
)
197194
if ("testme" %in% search()) detach(name = "testme")
198195
testme <- attach(testme_config, name = "testme", warn.conflicts = FALSE)
199196
rm(list = c("tags", "testme_package", "testme_name", "testme_file"))
200197

201-
198+
202199
## -----------------------------------------------------------------
203200
## Filters
204201
## -----------------------------------------------------------------
@@ -289,7 +286,8 @@ testme_run_test <- function(testme) {
289286
if (testme[["status"]] != "skipped") {
290287
if (testme[["debug"]]) message("Running test script: ", sQuote(testme[["script"]]))
291288
testme[["status"]] <- "failed"
292-
if (testme[["covr"]] != "none") {
289+
str(testme[["coverage"]])
290+
if (testme[["coverage"]] != "none") {
293291
pkg_env <- pkgload::load_all()
294292
cov <- covr::environment_coverage(pkg_env[["env"]], test_files = testme[["script"]])
295293
## Keep source files with non-zero coverage
@@ -345,11 +343,11 @@ testme_run_test <- function(testme) {
345343
message("Source files covered by the test script:")
346344
if (length(cov) > 0) {
347345
print(cov)
348-
if ("tally" %in% testme[["covr"]]) {
346+
if ("tally" %in% testme[["coverage"]]) {
349347
tally <- covr::tally_coverage(cov)
350348
print(tally)
351349
}
352-
if ("report" %in% testme[["covr"]]) {
350+
if ("report" %in% testme[["coverage"]]) {
353351
html <- covr::report(cov, browse = FALSE)
354352
browseURL(html)
355353
Sys.sleep(5.0)

tests/test-makeClusterSequential.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#! /usr/bin/env Rscript
2+
## This runs testme test script inst/testme/test-makeClusterSequential.R
3+
## Don't edit - it was autogenerated by inst/testme/deploy.R
4+
future:::testme("makeClusterSequential")

0 commit comments

Comments
 (0)