dwww Home | Show directory contents | Find package

test_that("suppress output", {
  if (getRversion() >= "4.0.0") {
    cnd <- NULL
    tryCatch(
      suppressMessages(cli_text("foo"), "cliMessage"),
      message = function(cnd2) cnd <<- cnd2
    )
    expect_null(cnd)
  }

  mysuppress <- function(expr) {
    withCallingHandlers(
      expr,
      cliMessage = function(msg) invokeRestart("muffleMessage")
    )
  }

  cnd <- NULL
  tryCatch(
    mysuppress(cli_text("foo")),
    message = function(cnd2) cnd <<- cnd2
  )
  expect_null(cnd)
})

Generated by dwww version 1.15 on Wed May 22 15:45:36 CEST 2024.