tibblify icon indicating copy to clipboard operation
tibblify copied to clipboard

Add CI/CD tests with `gctorture2(1, inhibit_release = TRUE)`

Open krlmlr opened this issue 2 years ago • 7 comments

Running the full test suite with gctorture() is prohibitive. I think it might be possible to devise a minimal set of tests, and in these tests to run only the tibblify() call in gctorture() . The following set of tests (to be stored in covr.R) already gives 50% of coverage:

tibblify(list())

spec <- spec_object(
  a = tib_dbl("a")
)
try(tibblify(list(a = 1:2), spec = spec))
try(tibblify(list(), spec = spec))
try(tibblify(list(a = 1, a = 1), spec = spec))
try(tibblify(list(1), spec = spec))
try(tibblify(list(1, b = 1), spec = spec))

spec <- spec_object(
  a = tib_dbl("a", transform = as.numeric)
)
tibblify(list(a = "1"), spec = spec)

spec <- spec_object(
  a = tib_scalar("a", hms::hms(), transform = hms::hms)
)
tibblify(list(a = 1), spec = spec)

I am using the following script (e.g. in run.R) to find the next uncovered item:

library(tidyverse)

r_files <- fs::dir_ls("R", glob = "*.R")
# already has 100% coverage
c_files <- fs::dir_ls("src", glob = "*.c")
files <- c(r_files, c_files)

text <- map(rlang::set_names(files), readLines)
line_exclusions <- map(text, seq_along)

covr <- covr::package_coverage(type = "none", line_exclusions = line_exclusions, code = paste(readLines("covr.R"), collapse = "\n"))
covr::report(covr)

This script runs in just a few seconds. Run this script, find the next uncovered line, devise code that triggers that line, rinse, repeat.

The goal would be to:

  • [ ] expand the set of minimal tests to get ~100% coverage for the C++ code
  • [ ] further minimize the set of tests keeping full coverage
  • [ ] implement and use gctorture_tibblify() in those tests
  • [ ] if needed, split the tests into multiple files so that each runs in just a few seconds even with gctorture
  • [ ] perhaps skip_if_ci() those tests, or run them in a special step on GHA

Follow-up to #113.

krlmlr avatar Jun 28 '22 01:06 krlmlr