Skip to content

GENERATE + conditional DYNAMIC_SECTION causes infinite loop #2025

Description

@Aivean

Describe the bug

My code uses generated bool to conditionally create a dynamic section. When I try run test with filter by this generated section, catch2 seems to run test in a loop indefinitely.

Expected behavior

I'm not sure what is the correct behavior here, but I doubt that infinite loop is expected.
If this is an illegal usage of generators and sections, perhaps it should be explicitly documented and/or an error should be generated.
Ideally I'd expect it to be able to filter by this dynamic generated section.

Reproduction steps
Steps to reproduce the bug.

Test case:

TEST_CASE( "generate_cond_section" )
{
    bool fov = GENERATE( false, true );
    DYNAMIC_SECTION( "fov_" << fov ) {
    }
}

When run without filter by section:

$ tests/test  "generate_cond_section"
Starting the actual test at Tue Sep 15 17:59:40 2020
Filters: generate_cond_section
0.000 s: fov_0
0.000 s: generate_cond_section
0.000 s: fov_1
0.000 s: generate_cond_section
===============================================================================
test cases: 1 | 1 passed
assertions: - none -

When run with filter by section:

$ tests/test  "generate_cond_section" -c fov_0
Starting the actual test at Tue Sep 15 18:00:55 2020
Filters: generate_cond_section
0.000 s: fov_0
0.000 s: generate_cond_section
0.000 s: generate_cond_section
0.000 s: generate_cond_section
0.000 s: generate_cond_section
0.000 s: generate_cond_section
0.000 s: generate_cond_section
0.000 s: generate_cond_section
0.000 s: generate_cond_section
0.000 s: generate_cond_section
0.000 s: generate_cond_section
....
^C

Platform information:

  • OS: MacOS 10.14
  • Compiler+version: Apple LLVM version 10.0.0 (clang-1000.11.45.5)
  • Catch version: v2.13.0

Additional context

I'm exploring my options to somehow "name" the values generated using the GENERATE, so I can run test for the specific combination of generated values. When I tried to use DYNAMIC_SECTION (or just SECTION) for that, I've encountered this bug.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions