Skip to content

Accurate position of messages in test log #1950

Open
@olivroy

Description

@olivroy

Follow-up to this

#1459

Sometimes there are messages in tests, but they can be hard to locate, could there be an handling similar to how warnings are handled?

Warnings are easy to locate to go silence and / or add expect_warning() / suppressWarnings(), but you have to run tests one by one to find the source of a message.

Is there a way testthat could make that easier by giving the source of messages?

Possibly that to avoid messing with CI, and it is probably not that useful in CI, maybe just in Build Pane or in interactive sessions, where cli hyperlinks are quite handy to locate warnings!

Edit: maybe adding to tests/testthat/setup.R would work?

# Only on testing (not R CMD CHECK)
if (!on_ci() && !interactive() && Sys.getenv("RSTUDIO", "true") == "true" && !Sys.getenv("R_CMD_CHECK", "true")) {
   cli::cli_inform("Activated global entrace")
   rlang::global_entrace()
}

or make them less prominent with col_silver()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions