Sections are not executed if external entropy provided in section name.
- Dominant language
- C++
- Stars
- 21.5k
- Forks
- 3.5k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 2
Description
**Describe the bug**
- Some sections are not run when clearly they should have been run.
- If catch2 figures out something is fishy: it needs to assert! Having silent failure is a bug in its own.
**Expected behavior**
All test section run.
**Reproduction steps**
Repro case:
```
SCENARIO("repro", "repro")
{
int foo = rand();
GIVEN("foo=" << foo)
{
}
GIVEN("test")
{
// should always fail, never executed
CHECK_FALSE(true);
}
}
```
**Platform information:**
- Catch version: **v2.4.2**
**Additional context**
So I was able to fix this by changing this part like this:
```
ITrackerPtr TrackerBase::findChild( NameAndLocation const& nameAndLocation ) {
auto it = std::find_if( m_children.begin(), m_children.end(),
[&nameAndLocation]( ITrackerPtr const& tracker ){
return
tracker->nameAndLocation().location == nameAndLocation.location;
// this is broken
// && tracker->nameAndLocation().name == nameAndLocation.name;
} );
return( it != m_children.end() )
? *it
: nullptr;
}
```
But this way it's impossible to have two sections on the same line, our codebase is ok with this limitation.
A proper fix would be to use statics for section initialization (like here https://github.com/jonasmr/microprofile/blob/master/microprofile.h#L255 ), this way we will be able to track sections regardless of their name.
Any ideas how to fix it better? :)
Contributor guide
Assessment
This issue has not been assessed yet.