GithubHelp home page GithubHelp logo

Nested sections are not run about catch2 HOT 14 CLOSED

catchorg avatar catchorg commented on May 23, 2024
Nested sections are not run

from catch2.

Comments (14)

philsquared avatar philsquared commented on May 23, 2024

Yikes! I see the problem - and know how I broke it.
Will have a fix soon. Thanks for pointing it out.

from catch2.

wichert avatar wichert commented on May 23, 2024

Hi Phil. I was wondering if you can provide an indication when you'll have a fix for this?

from catch2.

philsquared avatar philsquared commented on May 23, 2024

Hi wichert.
I have a little backlog of smaller issues to get through first - as this will require a bit more attention. I'm hoping to be on it this week, though.

from catch2.

philsquared avatar philsquared commented on May 23, 2024

I've checked in an initial improvement. It's not a complete fix but it might get you out of trouble for now.
I'm working on a complete fix now.

from catch2.

philsquared avatar philsquared commented on May 23, 2024

Sorry - I should have said what this fixes. It should work if there is a single subsection

from catch2.

philsquared avatar philsquared commented on May 23, 2024

I checked in a more complete fix now. It passes the skimpy tests I have in there but I need to add more before I can really say this is done. Would appreciate your feedback if you give it a try, though.

from catch2.

wichert avatar wichert commented on May 23, 2024

I will do some more testing in the next few days. I should be able to provide feedback before Monday.

from catch2.

philsquared avatar philsquared commented on May 23, 2024

Cool, thanks

from catch2.

wichert avatar wichert commented on May 23, 2024

One thing I noticed is that nested sections are not shown running the tests with -s. With the above example the output looks like this:

Running: MyClass
[Start section: 'defaults']
..
[End of section: 'defaults' ..]

Notice how the MyClass::MyClass level is skipped in the output.

from catch2.

wichert avatar wichert commented on May 23, 2024

So far everything is looking correct: tests in nested sections are run correctly, and the XML report shows them as well.

I'll leave closing this until you have decided if the nested sections should be shown in the -s output, which they are not at the moment.

from catch2.

wichert avatar wichert commented on May 23, 2024

Found a possible problem. I have a test which looks like this:

TEST_CASE("MyClass", "MyClass basic tests") {
    SECTION("MyClass::MyClass", "MyClass constructor tests") {
        MyFixture fixture;

        SECTION("defaults", "Default values for member varirables") {
             // ...
        }
        SECTION("other", "Other tests") {
             // ...
        }
    }
}

MyFixture is a simple class which prepares a test environment in its constructor and rests everything in its destructor. The test segfault in a way which suggests that the fixture is torn down before the "other" section is run.

Is there another way to setup test fixture? I couldn't find anything in the tests, and this pattern felt quite natural.

from catch2.

wichert avatar wichert commented on May 23, 2024

I found an error in my test fixture which caused the segfault. As far as I can see nested sections work correctly now.

from catch2.

philsquared avatar philsquared commented on May 23, 2024

Cool - glad you found the issue. I couldn't see any way that the scoping wouldn't have worked.

As for the -s reporting issue - thanks for pointing that out. It only occurred if a parent test had no assertions of its own (which would commonly be the case, but none of my meta tests were written that way! :-s ). Anyway, I've reproduced in the meta-tests and it's now all fixed. Would appreciate your verification, though.

from catch2.

wichert avatar wichert commented on May 23, 2024

Looks fine, thanks!

from catch2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.