tests/testthat/helper-warnings.R

# Every warning a call raises rather than the first matching one: some tests
# require exactly one (a second one, such as brms dropping rows, can be the bug
# itself), others look for an expected warning among several.
collect_warnings <- function(expr) {
  warnings <- character()
  value <- withCallingHandlers(expr, warning = function(w) {
    warnings <<- c(warnings, conditionMessage(w))
    invokeRestart("muffleWarning")
  })
  list(value = value, warnings = warnings)
}

Try the bmm package in your browser

Any scripts or data that you put into this service are public.

bmm documentation built on Oct. 16, 2026, 9:08 a.m.