"TAPlug"s for TAP::Harness

Eric Wilhelm scratchcomputing at gmail.com
Wed Jun 10 06:51:41 GMT 2009


# from Nicholas Clark
# on Tuesday 09 June 2009 14:47:

>If  module 1 is on CPAN does cool feature A by subclassing
> TAP::Harness and module 2 is on CPAN does cool feature B by
> subclassing TAP::Harness
>
>then how do I get cool features A and B?
>
>I'm not sure what the solution to that is, apart from "make it
> pluggable",

There already are some hooks defined.

      parser_args
      made_parser
      before_runtests
      after_runtests
      after_test

Though apparently lacking some documentation?

And (at a glance) it doesn't look like it's possible to stack more than 
one callback at any point.  Andy?

Now, of course the thing David was on about is that you have to be 
writing code with "TAP::Harness->new(...)" to set such callbacks and it 
is too many layers of abstraction away from the gripping end of the 
stick.

What I propose as a possible interface is to empower new() to load and 
probe a list of "Provides Lesser-Used Goodies" classes.  (Not really 
roles, but playing a similar, uh... role.)

  TAP::Harness->new(
    ...
    utilize => [
      ["TAPlug::Archiver", @args_for_init],
      ["TAPlug::Ponies", color => "red"],
      ...
    ],
  );

Wherin "TAPlug::Archiver->init($harness, @args_for_init)" returns a hash 
with $callback_name => $subref, each of which is then installed in the 
$harness object.  TAP::Harness would be responsible for require()ing 
each plug.

These plugs could be thin setup layers on top of whatever mechanism is 
needed, or might just implement everything in the returned subref.

This would mean that callers like Module::Build can add e.g. a --taplug 
option following perl's -M conventions of "Module=arg,arg".

  ./Build test --taplug Archiver=args,for,init --taplug Ponies=color,red

Plugs would be responsible for not breaking each other (or sufficiently 
educating the user about how to mix them), but by having the $harness 
object at their init(), they could conceivably introspect any existing 
plugs (assuming that TAP::Harness retains package names in an ordered 
list of who got where when.)

--Eric
-- 
Those who cannot remember the past are condemned to repeat it.
--George Santayana
---------------------------------------------------
    http://scratchcomputing.com
---------------------------------------------------


More information about the tapx-dev mailing list