-
Notifications
You must be signed in to change notification settings - Fork 341
Closed
Description
Suppose a test file has the contents:
skip("I don't want to run these")
test_that("multiplication works", {
expect_equal(2 * 2, 4)
})devtools::test() gives:
โน Testing example.test
Starting 1 test process
โ | F W S OK | Context
โ ผ [ FAIL 0 | WARN 0 | SKIP 0 | PASS 0 ] Starting up...
Error in self$snaps[[variant]][[test]] :
attempt to select less than one element in get1indexThis occurs within here:
testthat/R/snapshot-file-snaps.R
Lines 49 to 61 in dbe8883
| reset = function(test, old) { | |
| for (variant in names(self$snaps)) { | |
| cur_test <- self$snaps[[variant]][[test]] | |
| old_test <- old$snaps[[variant]][[test]] | |
| if (length(cur_test) == 0) { | |
| self$snaps[[variant]][[test]] <- old_test | |
| } else if (length(old_test) > length(cur_test)) { | |
| self$snaps[[variant]][[test]] <- c(cur_test, old_test[-seq_along(cur_test)]) | |
| } | |
| } | |
| invisible() | |
| }, |
because test is not set, and so is just an empty character vector. It looks like we are checking for NULL here:
https://github.com/r-lib/testthat/blob/main/R/snapshot-reporter.R#L119-L121
but this change coerces NULL to character(0):
so that change probably needs to be updated to handle any kind zero-length vector.
Metadata
Metadata
Assignees
Labels
No labels