Skip to content

Commit 8096e54

Browse files
committed
Send a skip rather than a regression condition
1 parent b2bfaf0 commit 8096e54

File tree

2 files changed

+3
-24
lines changed

2 files changed

+3
-24
lines changed

R/testthat-ui.R

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -199,30 +199,11 @@ case_declare <- function(case, fig_name) {
199199
}
200200

201201
new_expectation <- function(msg, case, type, vdiffr_type) {
202-
exp <- vdiffr_expectation(type, msg)
202+
exp <- testthat::expectation(type, msg)
203203
classes <- c(class(exp), vdiffr_type)
204204
structure(exp, class = classes, vdiffr_case = case)
205205
}
206206

207-
# FIXME: Use `testthat::expectation()` once it supports regressions
208-
vdiffr_expectation <- function(type, message, srcref = NULL) {
209-
type <- match.arg(type, c("success", "failure", "error", "regression", "skip", "warning"))
210-
211-
structure(
212-
list(
213-
message = message,
214-
srcref = srcref
215-
),
216-
class = c(
217-
paste0("expectation_", type),
218-
"expectation",
219-
# Make broken expectations catchable by try()
220-
if (type %in% c("failure", "error")) "error",
221-
"condition"
222-
)
223-
)
224-
}
225-
226207
new_exp <- function(msg, case) {
227208
new_expectation(msg, case, "skip", "vdiffr_new")
228209
}
@@ -234,11 +215,9 @@ mismatch_exp <- function(msg, case) {
234215
msg <- "The vdiffr engine is too old. Please update vdiffr and revalidate the figures."
235216
new_expectation(msg, case, "skip", "vdiffr_mismatch")
236217
} else if (is_ci()) {
237-
# FIXME: Remove this branch once testthat interprets regressions
238-
# as failures on CI
239218
new_expectation(msg, case, "failure", "vdiffr_mismatch")
240219
} else {
241-
new_expectation(msg, case, "regression", "vdiffr_mismatch")
220+
new_expectation(msg, case, "skip", "vdiffr_mismatch")
242221
}
243222
}
244223

tests/testthat/test-expectations.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test_that("Mismatches are skipped except on CI and interactively", {
1212

1313
skipped_result <- subset_results(test_results, "test-failed.R", "mismatches are skipped when NOT_CRAN is unset")[[1]]
1414
expect_match(skipped_result$message, "Figures don't match: myplot.svg\n")
15-
expect_is(skipped_result, "expectation_regression")
15+
expect_is(skipped_result, "expectation_skip")
1616
})
1717

1818
test_that("Duplicated expectations issue warning", {

0 commit comments

Comments
 (0)