[Pdx-pm] Test::Builder calling convention

Michael G Schwern schwern at pobox.com
Tue Mar 17 17:20:34 PDT 2009


benh wrote:
> If we decupple the display then we can essentually template out any
> given data to be TAP. That said what would you want this to look like
> as data?
> 
> my $data = {
>  tests => [
>   { pass => 0, have => 'foo', want => 'bar', file => 't/foo.t', line => 23 },
>   { pass => 0, msg => 'Failed test in t/foo.t at line 23.' }
>  ],
>  msg => 'I like pie',
> };

That loses order.  It would have to be more like this:

  my @data = [
      { pass => 0, have => 'foo', want => 'bar', file => 't/foo.t', line => 23 },
      { pass => 0, msg => 'Failed test in t/foo.t at line 23.' },
      { msg => 'I like pie' },
  ];

That represents in TAP...

not ok 1
  ---
  have: foo
  want: bar
  file: t/foo.t
  line: 23
  ...
not ok 2
# Failed test in t/foo.t at line 23.
# I like pie

Except they'd all be objects.  2 test result objects and 1 message object.

Test::Builder2::History already stores this, but it doesn't hold onto
unrelated messages.  I don't know if its worthwhile to do so, I haven't heard
a use case for it.  It's getting close to round tripping.

I suppose if there's an output format that absolutely does not stream, one
that can't be built up as we go, it would need to store everything and output
in one shot.  Even XML isn't that inflexible.


> I know that TAP has some limitations in the formating of #2 and #3 but
> is there any reason to keep that limitation in the way that things are
> structured?

Nope.



More information about the Pdx-pm-list mailing list