Catch2
Catch2 copied to clipboard
Section filter command line option only works for sections without whitespace in name
Describe the bug Section filter command line option only works for sections without whitespace in name
Expected behavior "section 1" should be run and "section 2" should not be run
Reproduction steps Given input
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
TEST_CASE("Test case", "[mve]") {
SECTION("section"){
SECTION("section 1") {
REQUIRE(true==false);
}
SECTION("section 2") {
REQUIRE(true==true);
}
}
}
$ ./MyTest -c "section 1"
Platform information:
- OS: Ubuntu 5.15.0-1049-realtime
- Compiler+version: Intel(R) oneAPI DPC++/C++ Compiler 2023.0.0 (2023.0.0.20221201)
- Catch version: v2.13.10
Additional context Add any other context about the problem here.
This seems to be misunderstanding of how -c works. -c form a stack, so to select "A 1" section here, you have to pass -c A -c "A 1".
TEST_CASE( "#2848" ) {
SECTION( "A" ) {
std::cout << "A\n";
SECTION( "A 1" ) { std::cout << "A1\n"; }
SECTION( "A 2" ) { std::cout << "A2\n"; }
}
}
./tests/SelfTest "#2848" -c A -c "A 1"
Filters: "#2848"
Randomness seeded to: 1738735499
A
A1
===============================================================================
test cases: 1 | 1 passed
assertions: - none -