catchorg / catchorg/Catch2

Improve --durations output format for nested sections

Open
#2,727 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
21.5k
Forks
3.5k
Avg merge
3d 16h
Merged PRs (30d)
2

Description

### 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
```

Contributor guide

Open the contributing guide

Research direction

The issue names the --durations=yes command-line output and provides nested TEST_CASE/SECTION examples. Start by tracing the duration-reporting path and compare its current output with the desired aggregated, prefixed format. Done means nested names are readable and each case or section reports an aggregated duration without duplicate entries.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.