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

Add ability to filter subcases with filters #57

Closed
onqtam opened this issue Mar 21, 2017 · 6 comments
Closed

Add ability to filter subcases with filters #57

onqtam opened this issue Mar 21, 2017 · 6 comments

Comments

@onqtam
Copy link
Member

onqtam commented Mar 21, 2017

No description provided.

onqtam added a commit that referenced this issue Mar 21, 2017
- the filters are "--subcase=" and "--subcase-exclude="
- there is also the option "--subcase-filter-levels=<int>" which affects which levels of nested subcases should check the filters
@onqtam
Copy link
Member Author

onqtam commented Mar 21, 2017

Given the following code:

TEST_CASE("Test") {
    cout << "root" << endl;
    SUBCASE( "sa" ) {
        cout << "sa" << endl;
        SUBCASE( "sb" ) {
            cout << "sb" << endl;
        }
        SUBCASE( "sc" ) {
            cout << "sc" << endl;
        }
    }
    SUBCASE( "sd" ) {
        cout << "sd" << endl;
    }
}
  • To execute only sa / sb run with --subcase=sa,*b - wildcards may be used just as with all other filters
  • To execute everything inside of sa without having to explicitly list the names of the nested subcases run with --subcase=sa --subcase-filter-levels=1 - meaning that the filters will be applied only to the first <int> levels of nested subcases

This is still in the dev branch though...

@iamviji
Copy link

iamviji commented Aug 5, 2021

how to execute only one leaf test case? for example sb-level1/sb-level-2/sb-level3

@onqtam
Copy link
Member Author

onqtam commented Aug 5, 2021

@iamviji in the example from this issue the following works to execute one specific leaf: -sc=sa,sb (or -sc=sa,sc for the other nested subcase) - you effectively have to specify all the subcases in the path to the leaf in the comma-separated list.

@iamviji
Copy link

iamviji commented Aug 5, 2021

Thanks. I have tried that.

    TEST_CASE("TC")
    {
        MESSAGE("TC");
        SUBCASE("SB1")
        {
            MESSAGE("TC.SB1");
            SUBCASE("SB1") { MESSAGE("TC.SB1.SB1"); }
            SUBCASE("SB2") { MESSAGE("TC.SB1.SB2"); }
        }
        SUBCASE("SB2")
        {
            MESSAGE("TC.SB2");
            SUBCASE("SB1") { MESSAGE("TC.SB2.SB1"); }
            SUBCASE("SB2") { MESSAGE("TC.SB2.SB2"); }
        }
    }

command tried:
-tc=TC -sc=SB1,SB2

output:
MESSAGE:TC
MESSAGE:TC.SB1
MESSAGE:TC.SB1.SB1
MESSAGE:TC
MESSAGE:TC.SB1
MESSAGE:TC.SB1.SB2
MESSAGE:TC
MESSAGE:TC.SB2
MESSAGE:TC.SB2.SB1
MESSAGE:TC
MESSAGE:TC.SB2
MESSAGE:TC.SB2.SB2

but I expect
MESSAGE:TC
MESSAGE:TC.SB1
MESSAGE:TC.SB1.SB2

@onqtam
Copy link
Member Author

onqtam commented Aug 5, 2021

@iamviji there are identical subcase names which are nested within each other. Try with different names like this:

    TEST_CASE("TC")
    {
        MESSAGE("TC");
        SUBCASE("SB1_root")
        {
            MESSAGE("TC.SB1_root");
            SUBCASE("SB1") { MESSAGE("TC.SB1_root.SB1"); }
            SUBCASE("SB2") { MESSAGE("TC.SB1_root.SB2"); }
        }
        SUBCASE("SB2_root")
        {
            MESSAGE("TC.SB2_root");
            SUBCASE("SB1") { MESSAGE("TC.SB2_root.SB1"); }
            SUBCASE("SB2") { MESSAGE("TC.SB2_root.SB2"); }
        }
    }

-sc=SB1_ROOT,SB2

I guess this could be investigated and may be a little confusing... Or the docs should say that nested subcases shouldn't have identical names.

@iamviji
Copy link

iamviji commented Aug 5, 2021

I see

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