YANWT (Yet Another No-Warnings Tester)

A few weeks ago a casual exchange occured on irc... I might as well quote it rather than paraphrase:

11:26 * GumbyNET7 CPAN Upload: Test-Roo-0.002 by DAGOLDEN http://metacpan.org/release/DAGOLDEN/Test-Roo-0.002
13:32 < ether> booo done_testing--
13:32 < ether> Y U NO LIKE Test::NoWarnings
13:33 < ether> I do have a tuit item to make Test::NoWarnings play nicer with done_testing.. others have also opened tickets about it
13:33 < ether> but for now, I like Test::NoWarnings more than I dislike counting my tests.
13:43 <@xdg> I feel like there ought to be a better way than Test::NoWarnings
13:43 <@xdg> ether, go check out Test::Roo, btw
13:48 <@xdg> ether, really, if Test::NoWarnings didn't force an END block, then you could just import "had_no_warnings" and do "had_no_warnings; done_testing" at the end
14:03 < ether> Test::NoWarnings should import its own version of done_testing that does that automatically
14:03 < ether> I like the 'set it and forget it' feature of TNW
14:03 < ether> actually.. this is totally doable if we can detect in the END block if done_testing has already been called
14:03 < ether> if it hasn't, add an extra test as normal
14:04 < ether> if it has, do nothing, because done_testing already did the check
14:05 < ether> hell yeah, this is totally doable
14:05 * ether scribbles notes
14:08 * ether cries.. finds a note dated March 2011 with this exact same thought.
14:08 < ether> ETOOMANYTUITS
14:09 < ether> er tuit items, not tuit timeslots
14:09 <@xdg> ether, how about this: https://gist.github.com/dagolden/5033795
14:09 <+dipsy> [ Test::NoWarnings ]
14:09 <@xdg> er, Test::FailWarnings, I mean
14:10 <@xdg> it just throws fails() on warnings.
14:10 <@xdg> easy
14:28 < ether> hmmm
14:28 < ether> Test::NoWarnings is quite pervasive, so I see the appeal in fixing it rather than (or as well as?) creating something new
14:32 < ether> TNW is pretty crufty though
14:32 < ether> I'll ponder more tonight. paid work is beckoning again.
14:45 <@xdg> ether, I just shipped it. Feel free to use/enhance. :-)
14:46 * GumbyNET7 CPAN Upload: Test-FailWarnings-0.001 by DAGOLDEN http://metacpan.org/release/DAGOLDEN/Test-FailWarnings-0.001
14:54 < ether> lol
14:54 <@xdg> dzil just makes it way too easy

And that was that! But wait...

I'm somewhat fond of test counts (occasionally I comment out some tests to avoid them getting in the way of debugging something else, for example), so I like having that extra check that I haven't omitted something I shouldn't. But I'd still like to be able to use the same no-warnings tester as if I were using done_testing, so I can switch back and forth between having a plan, or not, without having to change other things.

My round tuit supply has been short of late, so I've had to chew on this idea in small morsels. Today however I made a bit of time, so I was able to bash out an implementation of my idea -- Test::Warnings (or https://metacpan.org/release/ETHER/Test-Warnings-0.001-TRIAL).

It's released as TRIAL for now, to demonstrate it's still experimental (as per CPAN is for experimentation and I hope that never changes (hey, look it's Dave again.. do I see a pattern here.. ;) ), but I do hope this proves to be useful, and I definitely don't intend to abandon the module as long as it is.

I've also learned some new interesting things about the toolchain and how Test::Builder works... if you look at the commit history on github you'll see I had to make a few hacks to allow everything to work and let me test everything with Test::Tester (and even then, I couldn't test done_testing explicitly with Test::Tester, as once done_testing is called, there can be no more tests, at any level!).

I'm also planning on adding more features soon, tuits-dependent of course. :)

And with that, this ends my first blog post, and third self-authored CPAN distribution. It's been a good day.

3 Comments

it is under "Manage" -> "Entries".
Then click on the entry you would like to edit, save & done.

Leave a comment

About Ether

user-pic I blog about Perl.