[R-pkg-devel] Problems with too much testing
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Fri Apr 16 12:08:58 CEST 2021
I'm updating the rgl package, and have come across the following problem.
Some packages that depend on rgl and do careful testing are detecting
inconsequential changes. A typical case is the nat package, which has
extensive testing, some of which comes down to checking results from rgl
functions using testthat::is_equal(). I rewrote some parts of the rgl
code, and so some rgl objects differ in irrelevant ways. For example,
obj <- list(x = NULL)
differs from
obj <- list()
obj[["x"]] <- NULL
(the first is length 1, the second ends up with no entries). All tests
in rgl would be like
if (is.null(obj[["x"]])) ...
so the tests evaluate the same, but testthat::is_equal() doesn't return
TRUE, because the objects are different.
Another example would be
obj <- list()
obj$a <- 1
obj$b <- 2
which differs from
obj <- list()
obj$b <- 2
obj$a <- 1
in the order of the components, but since rgl always accessed them by
name, that makes no difference.
So what I'm looking for is a strategy to hide internal implementation
details. (I'm using a compare_proxy() method now which standardizes the
objects, but that seems very specific to testthat version 3. I'd like
ideas for something more robust.)
Duncan Murdoch
More information about the R-package-devel
mailing list