A friend has written some monitor-type tests (is machine X pingable, etc) using Test::More, and now his customer wants the output to be more "user friendly", say, like, "Test 6 of foo.t failed: POP server foo doesn't respond" etc. He asked how best to do this and I'm toying with a couple of ideas for intercepting the TAP output so I can munge it to the customer's desire.

First is to tie STDOUT and STDERR and grab the output that way. I haven't tried that yet because I experimented instead with redefining Test::Builder::_print() as follows via a module that would replace Test::More in my friend's test. Any suggestions for the best approach to take?

package Testicle; use Test::Builder::Module; require Test::More; our @ISA = qw(Test::More); use base 'Exporter'; our @EXPORT = @Test::More::EXPORT; Test::More->import; my $builder; BEGIN { $builder = Test::Builder::Module->builder; my $class = ref $builder; no strict 'refs'; no warnings 'redefine'; *{ "${class}::_print" } = sub { shift; "Have my way with @_" }; }
Peter Scott
Perl Medic

In reply to Intercepting TAP output by peters

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.