Changes to Test::Builder/More/Simple incoming
A couple months back Schwern handed me the keys to Test::Builder and friends. Initially I planned to try and knock out little bugs and simply maintain stability... That plan failed and I ended up spending a lot of time giving it a major overhaul for a feature Schwern and I agreed would be very nice. Result Streaming. This was further prompted by a minor change to a specific diagnostic message that resulted in breaking fragile tests written with Test::Builder ::Tester, which frankly, has seen better days. THERE IS A BETTER WAY!
I have just released an ALPHA version of the Test-Simple dist. This dist includes the following changes and features:
- Results from Test::Builder are objects, and are funneled to a a stream which distributes them to any number of listeners/formatters
- TAP is the default formatter, you can have any number of listeners, and you can disable TAP if desired.
- Test::Tester2 is present, and can be used to intercept and validate the result stream. With this Test::Tester and Test::Builder::Tester are deprecated.
- Testing tools should use Test::Builder::Provider, this is because $Test::Builder::Level is now deprecated too (good riddance!)
- There is some basic built-in forking support (must be turned on, off by default)
- Some old methods are deprecated (but still work)
- Test::Builder is not longer required to be treated as a singleton
- 5.6 support is dropped in order to facilitate some of this work
I want to Stress that unlike the mostly-dead Test::Builder2 and Test::Builder-1.5 branches, these changes were not a project reboot. These changes are refactors and additions, I did not start from the ground up. In addition these changes were designed to maintain comparability wherever possible. In its current form there are 3 known failures:
Please play with it, build stuff against it, and report any issues that are likely the result of these changes.
1) Test::SharedFork - Broken, but a simple 1 or 2 line pull is sitting on github waiting to be merged. Broken because it replaces methods in TB itself. FIXED
2) Some moose tests still have a hack for TB1.5, a pull request has been merged, and by the time anyone reads this it will likely be shipped and fixed.FIXED
3) A single Catalyst test fails... and I have no idea why and would LOVE any help anyone could give me. It appears some tests in the file never get run and I frankly do not understand the test. Pull request: https://github.com/plack/Plack/pull/462 will fix this
Docs to checkout:
- Test::Tester2 - A better way to Test your Testers
- Test::Builder::Provider - A better way to write a test library
- Test::Builder::Stream - Don't cross the streams... Stack them!
- Test::Builder::Formatter - Format the test output your way!
So what is the future of Test::* now? (Maybe a separate entry about that?)
Devel::Confess t/leak.t dies too with 'Unknown option: Can't prevent leaks without Scalar::Util::weaken at /home/skaufman/perl5/lib/perl5/Test/Builder/Provider.pm line 200.'
Samuel,
The problem there is with the test, not Test::Builder, though the changes in Test::Builder exposed the bug. Basically Test::Builder is getting these args:
$VAR1 = [
'tests',
3,
'Can\'t prevent leaks without Scalar::Util::weaken'
];
The problem is here:
4 use Test::More
5 defined &Scalar::Util::weaken ? (tests => 3)
6 : skip_all => "Can't prevent leaks without Scalar::Util::weaken";
that turnary is incorrect. The difference is that now Test::More keeps processing args after a skip_all.
It can be argued that a skip_all should stop arg processing, even so that doesn't change that the turnary is wrong.
https://github.com/haarg/Devel-Confess/pull/1