hi all. yesterday on irc we got to discussing adding a feature to Test::More that Apache-Test has been using for a while. the overall opinion was that the idea had merit, but we should vet out options here, so comments welcome. here's the scoop...
over in Apache-Test we allow users to join the plan and skip operations in a single step. so, whereas in Test::More you would do something like if ($condition) { plan tests => 3; } else { plan 'skip_all'; } Apache-Test allows a simple plan tests => 3, $condition; basically, if the arguments to plan() are unbalanced, the final argument is taken as a skip marker. of course, that's not the whole story, since I just glossed over the skip message, but that's the basic idea we're tossing around. here are the gory details. Apache-Test provides a few different interfaces for $condition, but the format for each is to populate a @global with the skip message. here's an example: plan tests => 3, need_lwp; # skip if the LWP suite is not found. where need_lwp would populate the global skip array behind the scenes, and the message would be printed as you would expect. for user-specific functions there is skip_message() plan tests => 3, skip_message('foo not found'); a final, interesting form is the special need() function, which will push skip messages onto this global array and print them all # skip unless we can do SSL in real time plan tests => 3, need need_lwp, need_module('LWP::Protocol::https'); in this case, if only LWP::Protocol::https was missing the skip message would be just for it, while if both were missing both skip messages would be printed. anyway, the point of this exercise is to present a few different options for augmenting Test::More's plan(). personally, I really, really like the way Apache::Test::plan() works, and would love to see that logic carried over to Test::More. the only real sticking issue is the use of a global array, which doesn't really fly with Test::Builder. so, were I to implement it now (off the top of my head) I would port plan(), skip_message(), and need() over to Test::Builder. the communication would use a new function Test::Builder::add_to_skip_message() (or somesuch) that would be the official accessor to some locally scoped message array. ok, now tear it to shreds :) --Geoff