Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Section filter command line option only works for sections without whitespace in name #2848

Open
chf2117 opened this issue Mar 27, 2024 · 1 comment

Comments

@chf2117
Copy link

chf2117 commented Mar 27, 2024

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.

@horenmar
Copy link
Member

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 -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants