Catch2 icon indicating copy to clipboard operation
Catch2 copied to clipboard

Nested sections remove INFO output

Open learn-more opened this issue 9 months ago • 1 comments

Describe the bug When using nested sections, the 'INFO' output is retired too early.

Expected behavior The 'INFO' output stays in place for all relevant scopes.

Reproduction steps In this example, the 'Info message!' is expected in both failure cases (4 == 1 and 2 == 1)

TEST_CASE( "NestedSection", "[broken]" ) {
    INFO( "Info message!" );
    SECTION( "outer" ) {
        SECTION( "inner" )
        {
            CHECK( 4 == 1 );    // The info shows fine here
        }
        CHECK( 2 == 1 ); // The info does not show up for this failing check
    }
}

Image

Platform information:

  • OS: Windows 10 22H2
  • Compiler+version: **MSVC 2022 **
  • Catch version: v3.8.0

I debugged it a bit this does not take into account that you can have nested sections at all

Image

learn-more avatar Feb 27 '25 08:02 learn-more

I'm struggling to find a reference, but I believe it's strongly recommended to not have statements after SECTIONs because of these types of issues.

andrewauclair avatar May 05 '25 16:05 andrewauclair

Thanks!

learn-more avatar Jul 22 '25 06:07 learn-more