Skip to content

Improving the output of the check reporterΒ #2183

@gaborcsardi

Description

@gaborcsardi

Motivation

One frustration I have with the check reporter is the lack of output, which make it hard to debug issues that are external to testthat. Common examples are messages from sanitizers, valgrind or crashes.

For example a recent run on the R-hub m1-san machine gave me this output:

[...]
  > library(testthat)
  > library(otelsdk)
  > 
  > test_check("otelsdk")
  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__chrono/duration.h:92:79: runtime error: signed integer overflow: 9221621549533571493 * 1000 cannot be represented in type '_Ct' (aka 'long long')
  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__chrono/duration.h:92:79 
  [ FAIL 0 | WARN 0 | SKIP 30 | PASS 172 ]
[...]

(https://github.com/r-lib/otelsdk/actions/runs/15792938235/job/44521285942#step:6:252)

Goals

  • Make it easier to match messages from test cases to tests.
  • Keep a summary of the test results at the end, so R CMD check prints it.
  • Informative messages for errors and test failures, as with all reporters.

I admit, that I keep forgetting why the output of the check reporter is so terse, so another important goal is potentially missing here.

Suggestion

I have an implementation for this output in a new reporter in the testthatlabs package. The output from this reporter, including the failure above looks like this:

  ❯ otelsdk test suite ───────────────────────────────────────────────────────────
  
       β€Ί checks 1 Β» is.na ..... ... [89ms]
       β€Ί checks 13 Β» is_string ..... . [13ms]
       β€Ί checks 23 Β» is_named ..... ... [17ms]
  
  SKIP β€Ί 'test-checks.R:37:3' Β» as_timestamp [On CRAN]
  SKIP β€Ί 'test-checks.R:63:3' Β» as_span [On CRAN]
  SKIP β€Ί 'test-checks.R:80:3' Β» as_span_context [On CRAN]
  
       β€Ί checks 95 Β» as_span_parent .... [20ms]

...

  SKIP β€Ί 'test-logger-provider-http.R:2:3' Β» logger_provider_http [On CRAN]
  SKIP β€Ί 'test-logger-provider-http.R:27:3' Β» logger_provider_http_options [On CRAN]
  
  
       β€Ί logger-provider-stdout 1 Β» logger_provider_stdstream .. [7ms]
       β€Ί logger-provider-stdout 8 Β» log to file ../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__chrono/duration.h:92:79: runtime error: signed integer overflow: 9221617979017900176 * 1000 cannot be represented in type '_Ct' (aka 'long long')
  SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.4.sdk/usr/include/c++/v1/__chrono/duration.h:92:79 
  . [44ms]
  
  SKIP β€Ί 'test-logger-provider-stdout.R:39:3' Β» log to file [On CRAN]
  SKIP β€Ί 'test-logger-provider-stdout.R:63:3' Β» logger_provider_stdstream_options [On CRAN]

...

       β€Ί utils 189 Β» plural ... [7ms]
       β€Ί utils 195 Β» find_instrumentation_scope . [4ms]
       β€Ί utils 204 Β» empty_atomic_as_null ..... [9ms]
  
  PASS x370  FAIL x0  WARN x0  SKIP x119  [4.3s]                                  

(https://github.com/r-lib/otelsdk/actions/runs/16677280319/job/47206943447#step:6:446)

Summary of the changes:

  • Report every test block.
  • Create a dot for every expectation, in groups of five, for easier counting.
  • Make special events (skips, warning, test failures) easy to discover from the output. You only need to scan the beginning of the lines to find them.

Screenshot of a test suite with special events, running locally:

Image

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