Catch2 icon indicating copy to clipboard operation
Catch2 copied to clipboard

Improve --durations output format for nested sections

Open vasdommes opened this issue 1 year ago • 0 comments

Current behaviour

Consider the following test structure:

TEST_CASE("TestCase-1")
  SECTION("Section-1")
    SECTION("Nested-1")
    SECTION("Nested-2")
  SECTION("Section-2")

If I run test with --durations=yes option, then the output looks like

1.000 s: Nested-1                                                       
1.100 s: Section-1                                                             
1.200 s: TestCase-1                                                            
2.000 s: Nested-2                                                       
2.100 s: Section-1                                                             
2.200 s: TestCase-1                                                            
1.000 s: Section-2                                                             
1.100 s: TestCase-1  

The problem

I find it hard to read because of two reasons:

  1. All cases and sections are on the same level, I cannot see nesting unless I write prefixes by hand, e.g. SECTION("TestCase-1::Section-1::Nested-2").
  2. Several separate durations are reported for TestCase-1 and Section-1, which doesn't make much sense to me - usually I want to see the total time for each case/section.

Desired behaviour

Ideally I'd like to get something like this - aggregated timings with prefixes (and any reasonable separator):

1.000 s: TestCase-1::Section-1::Nested-1        
2.000 s: TestCase-1::Section-1::Nested-2        
3.200 s: TestCase-1::Section-1              
1.000 s: TestCase-1::Section-2
4.500 s: TestCase-1

vasdommes avatar Aug 02 '23 23:08 vasdommes