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
Return value of subtest() #250
Comments
You're right, it was removed by accident. It's going to be a little more work |
Thank you for your reply! I dug deeper into the code using your precisions, and the following changes seem to fix the problem: TB2::TestState::handle_subtest_end(): return whether the test was successful.
Test::Builder::subtest(): return the value returned by post_event().
The test script previously mentioned then outputs the expected results:
Running the tests in t/ also doesn't seem to bring up any error that would be related to the change. I'm not pretending to fully understand the overall architecture, so please correct me if I'm on the wrong path. Otherwise, I'll be happy to submit a patch for your consideration. |
Thanks for digging into it! The solution will work, but I'd like it if A) subtest returned a Result object, not just a boolean and B) if things could just ask the SubtestEnd event for a result. B is the important part, because right now the logic is in the TAP formatter and if other formatters want to implement subtests they'd have to reimplement that logic. It improves the design. Lemme bang that together now. Thanks for inadvertently pushing me into it. :) |
That way a Formatter, or anything else, can just ask the SubtestEnd event. This necessitated attaching the SubtestStart event to SubtestEnd so it could have the necessary context to setup the Result. For #250
That should do it. |
Nice fix, thank you! I've just tested and it indeed solves the problem. |
I just noticed that subtest() in 0.94 returns a boolean indicating whether the subtests where successful, but 1.005000_002 doesn't. This feature is very useful for test modules to aggregate the results of a block of tests (I use it in Test::Dist::VersionSync for example).
Simple script to demonstrate the difference:
With 0.94, this returns:
With 1.005000_002, this returns:
If this feature was not intentionally removed, I'm willing to take a look at https://github.com/schwern/test-more/blob/Test-Builder1.5/lib/Test/Builder.pm and see what could be returned at line 188 to make it work again. Let me know!
The text was updated successfully, but these errors were encountered: