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

Using filter -sc does not work properly? #513

Closed
yudi-azvd opened this issue Jun 5, 2021 · 3 comments
Closed

Using filter -sc does not work properly? #513

yudi-azvd opened this issue Jun 5, 2021 · 3 comments

Comments

@yudi-azvd
Copy link

yudi-azvd commented Jun 5, 2021

Description

As described in the docs it should be possible to run only specified subcases using the flag -sc. But when I use it, all tests are executed. I know the subcases were registered/compiled because they are the only ones printing something on the screen and If I list tests cases or subscases everything is listed fine. I also tried --subcase.

Steps to reproduce

-sc="*the*" (the is present in both subcases ) and --subcase="*vectors*" did not work for me. I used the following examples from the docs.

TEST_CASE("vectors can be sized and resized") {
    std::vector<int> v(5);

    REQUIRE(v.size() == 5);
    REQUIRE(v.capacity() >= 5);

    SUBCASE("adding to the vector increases it's size") {
        v.push_back(1);

        CHECK(v.size() == 6);
        CHECK(v.capacity() >= 6);
    }
    SUBCASE("reserving increases just the capacity") {
        v.reserve(6);

        CHECK(v.size() == 5);
        CHECK(v.capacity() >= 6);
    }
}

Extra information

  • doctest version: v2.4.5
  • Operating System: Ubuntu 18.04
  • Compiler+version: gcc 7.5

2nd extra

doctest is an awesome framework! thank you for your effort :)

@yudi-azvd
Copy link
Author

yudi-azvd commented Jul 16, 2021

Ok... after some experimentation I realized that -sc only filters subcases. Test cases which do not include the filtered subcase will still be executed. Is that correct? Is that the intended behavior?

I thought -sc would only run subcases filtered by it. Reading the docs on -tc and -sc made me think this way.

@yudi-azvd yudi-azvd changed the title Using filter -sc does not work Using filter -sc does not work properly? Jul 16, 2021
@onqtam
Copy link
Member

onqtam commented Nov 10, 2021

Ok... after some experimentation I realized that -sc only filters subcases. Test cases which do not include the filtered subcase will still be executed. Is that correct? Is that the intended behavior?

I thought -sc would only run subcases filtered by it. Reading the docs on -tc and -sc made me think this way.

yes, -sc filters only subcases - -tc should be used alongside it if you want to filter test cases too. There's no way to know what subcases exist without actually executing all test cases.

I will add a note in the docs that subcase filtering does not affect test case filtering.

And glad you like the framework! :)

@onqtam onqtam closed this as completed Nov 10, 2021
onqtam added a commit that referenced this issue Nov 10, 2021
@yudi-azvd
Copy link
Author

Thanks xD

onqtam added a commit that referenced this issue Dec 10, 2021
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