Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# testthat (development version)

* Parallel testthat now does not ignore test files with syntax errors (#1360).
* `ParallelProgressReporter` now respect `max_failures` (#1162).
* The last snapshot is no longer lost if the snapshot file is missing the final newline (#2092). It's easy to accidentally remove this because there are two trailing new lines in snapshot files and many editors will automatically remove if you touch the file.
* New `expect_r6_class()` (#2030).
* `expect_*()` functions consistently and rigorously check their inputs (#1754).
* `expect_*()` functions consistently and rigorously check their inputs (#1754).
* `JunitReporter()` no longer fails with `"no applicable method for xml_add_child"` for warnings outside of tests (#1913). Additionally, warnings now save their backtraces.
* `JunitReporter()` strips ANSI escapes in more placese (#1852, #2032).
* `try_again()` is now publicised. The first argument is now the number of retries, not tries (#2050).
Expand Down
3 changes: 3 additions & 0 deletions R/parallel-taskq.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ task_q <- R6::R6Class(
private$tasks$state[[i]] <- "ready"
msg <- NULL
} else if (msg$code == PROCESS_DONE) {
if (!is.null(msg$error)) {
private$handle_error(msg, i)
}
private$tasks$state[[i]] <- "ready"
} else if (msg$code %in% PROCESS_FAILURES) {
private$handle_error(msg, i)
Expand Down
18 changes: 18 additions & 0 deletions tests/testthat/test-parallel-errors.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
test_that("error in parallel setup code", {
skip_on_covr()
withr::local_envvar(TESTTHAT_PARALLEL = "TRUE")
err <- tryCatch(
capture.output(suppressMessages(testthat::test_local(
test_path("test-parallel", "syntax-error"),
reporter = "summary"
))),
error = function(e) e
)
expect_s3_class(err, "testthat_process_error")
# contains test file's name
expect_match(conditionMessage(err), "test-error-1.R")
# contains original error message
expect_match(conditionMessage(err), "unexpected symbol")
# contains the text of the syntax error
expect_match(conditionMessage(err), "but this")
})
20 changes: 20 additions & 0 deletions tests/testthat/test-parallel/syntax-error/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Package: setup
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Authors@R:
person(given = "First",
family = "Last",
role = c("aut", "cre"),
email = "[email protected]",
comment = c(ORCID = "YOUR-ORCID-ID"))
Description: What the package does (one paragraph).
License: `use_mit_license()`, `use_gpl3_license()` or friends to
pick a license
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
Suggests:
testthat
Config/testthat/parallel: true
Config/testthat/edition: 3
2 changes: 2 additions & 0 deletions tests/testthat/test-parallel/syntax-error/NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated by roxygen2: do not edit by hand

4 changes: 4 additions & 0 deletions tests/testthat/test-parallel/syntax-error/tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(ok)

test_check("ok")
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test_that("this is good", {
expect_equal(2 * 2, 4)
})

but this is a syntax error!
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test_that("this fails", {
expect_equal(Sys.getpid(), 0L)
})
Loading