FAQ
Hi all!

Does anyone know of a Test::Harness extension or replacement that can color
the final report line in green if all tests passed and in red otherwise?
search.cpan.org is no help, and couldn't find anything relevant by a brief
scanning of its POD page there (but not a thorough reading of it).

I'd like to be able to use it without requiring the module's user to install
it, just using it on my local configuration.

Regards,

Shlomi Fish

---------------------------------------------------------------------
Shlomi Fish shlomif@iglu.org.il
Homepage: http://www.shlomifish.org/

95% of the programmers consider 95% of the code they did not write, in the
bottom 5%.

Search Discussions

  • Dave Cross at Sep 5, 2005 at 9:58 am

    Shlomi Fish wrote:
    Hi all!

    Does anyone know of a Test::Harness extension or replacement that can color
    the final report line in green if all tests passed and in red otherwise?
    search.cpan.org is no help, and couldn't find anything relevant by a brief
    scanning of its POD page there (but not a thorough reading of it).

    I'd like to be able to use it without requiring the module's user to install
    it, just using it on my local configuration.
    The Test::Builder::Tester distribution includes
    Test::Builder::Tester::Color. That might be useful - or might serve as a
    good basis to build something on.

    Dave...
  • Paul Johnson at Sep 5, 2005 at 11:29 am

    On Mon, Sep 05, 2005 at 10:58:17AM +0100, Dave Cross wrote:

    Shlomi Fish wrote:
    Hi all!

    Does anyone know of a Test::Harness extension or replacement that can
    color the final report line in green if all tests passed and in red
    otherwise? search.cpan.org is no help, and couldn't find anything relevant
    by a brief scanning of its POD page there (but not a thorough reading of
    it).

    I'd like to be able to use it without requiring the module's user to
    install it, just using it on my local configuration.
    The Test::Builder::Tester distribution includes
    Test::Builder::Tester::Color. That might be useful - or might serve as a
    good basis to build something on.
    See also Apache::Test.

    http://perl.apache.org/docs/general/testing/testing.html#Colored_Trace_Mode

    --
    Paul Johnson - paul@pjcj.net
    http://www.pjcj.net
  • Shlomi Fish at Sep 16, 2005 at 12:57 am
    (I'm CCing Andy Lester, the maintainer of Test::Harness here, because I'd like
    to consult with him)
    On Monday 05 September 2005 12:42, Shlomi Fish wrote:
    Hi all!

    Does anyone know of a Test::Harness extension or replacement that can color
    the final report line in green if all tests passed and in red otherwise?
    search.cpan.org is no help, and couldn't find anything relevant by a brief
    scanning of its POD page there (but not a thorough reading of it).

    I'd like to be able to use it without requiring the module's user to
    install it, just using it on my local configuration.
    OK, here's what I've discovered so far:

    1. Module::Build's "test" action has an hard-coded call to the Test::Harness
    API. It "require"s the Test::Harness module specifically and then calls its
    API functions.

    2. The statement that prints the message "All tests successful" is found
    within Test::Harness' _show_results function:

    <<<<
    sub _show_results {
    my($tot, $failedtests) = @_;

    my $pct;
    my $bonusmsg = _bonusmsg($tot);

    if (_all_ok($tot)) {
    print "All tests successful$bonusmsg.\n"; <-----------
    } elsif (!$tot->{tests}){
    die "FAILED--no tests were run for some reason.\n";
    } elsif (!$tot->{max}) {

    >>>>

    As one can see overriding it will require replacing the entire function.

    3. Test::Harness seems to use procedural code and so its functions cannot be
    easily overrided using @ISA and derived namespaces.

    ------------

    Thus, it seems the best option if we want to make sure Test::Harness is
    custmisable in this and other ways is to spin it off and create a better and
    more customizable test harnessing module, with an incompatible interface.
    Another option is to create an environment variable triggered option for this
    and future features, but that would be Evil.

    Mr. Lester, would you approve of a friendly spin-off of Test::Harness?

    Regards,

    Shlomi Fish

    ---------------------------------------------------------------------
    Shlomi Fish shlomif@iglu.org.il
    Homepage: http://www.shlomifish.org/

    95% of the programmers consider 95% of the code they did not write, in the
    bottom 5%.
  • Steve Peters at Sep 16, 2005 at 1:41 am

    On Fri, Sep 16, 2005 at 03:55:15AM +0300, Shlomi Fish wrote:

    Thus, it seems the best option if we want to make sure Test::Harness is
    custmisable in this and other ways is to spin it off and create a better and
    more customizable test harnessing module, with an incompatible interface.
    Another option is to create an environment variable triggered option for this
    and future features, but that would be Evil.

    Mr. Lester, would you approve of a friendly spin-off of Test::Harness?
    Another option would be to use Test::Harness::Straps. This seems a lot more
    easy than trying to write your own harness. Since its already included
    with recent Perls, that seems to make more sense than writing your own
    incompatible testing harness.

    Steve Peters
    steve@fisharerojo.org
  • Shlomi Fish at Sep 16, 2005 at 5:37 pm

    On Friday 16 September 2005 04:40, Steve Peters wrote:
    On Fri, Sep 16, 2005 at 03:55:15AM +0300, Shlomi Fish wrote:
    Thus, it seems the best option if we want to make sure Test::Harness is
    custmisable in this and other ways is to spin it off and create a better
    and more customizable test harnessing module, with an incompatible
    interface. Another option is to create an environment variable triggered
    option for this and future features, but that would be Evil.

    Mr. Lester, would you approve of a friendly spin-off of Test::Harness?
    Another option would be to use Test::Harness::Straps. This seems a lot
    more easy than trying to write your own harness. Since its already
    included with recent Perls, that seems to make more sense than writing your
    own incompatible testing harness.
    From a brief inspection of Test::Harness::Straps it seems that it doesn't give
    all the necessary functionality. Some logic is still present only in
    Test::Harness which makes uses of T::H::S.

    Regards,

    Shlomi Fish

    ---------------------------------------------------------------------
    Shlomi Fish shlomif@iglu.org.il
    Homepage: http://www.shlomifish.org/

    95% of the programmers consider 95% of the code they did not write, in the
    bottom 5%.
  • Andy Lester at Sep 16, 2005 at 2:37 pm

    On Fri, Sep 16, 2005 at 03:55:15AM +0300, Shlomi Fish (shlomif@iglu.org.il) wrote:
    Mr. Lester, would you approve of a friendly spin-off of Test::Harness?
    Why are you asking if I approve? You can do whatever you like with the
    source code for Test::Harness.

    xoa

    --
    Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance
  • David Golden at Sep 16, 2005 at 3:35 pm

    Andy Lester wrote:
    On Fri, Sep 16, 2005 at 03:55:15AM +0300, Shlomi Fish (shlomif@iglu.org.il) wrote:

    Mr. Lester, would you approve of a friendly spin-off of Test::Harness?

    Why are you asking if I approve? You can do whatever you like with the
    source code for Test::Harness.
    I think a polite question is wonderful (with potential answers ranging from
    "sure" to "hey, that's a cool idea, let's try a merge instead of a fork").

    After the recent CPANPLUS::Dist::Build debacle, a little politeness in the
    community is nice to see.

    David Golden
  • Andy Lester at Sep 16, 2005 at 3:56 pm

    On Fri, Sep 16, 2005 at 11:35:05AM -0400, David Golden (david@hyperbolic.net) wrote:
    I think a polite question is wonderful (with potential answers ranging from
    "sure" to "hey, that's a cool idea, let's try a merge instead of a fork").
    Sure, it's a polite question, but an unnecessary one. He can do
    whatever he likes with the source.

    Just color me skeptical. As soon as there's something tangible for me
    to say "Hey, let's try a merge instead of a fork" about.

    Email lists make it easy for people to say "hey I've got this great
    idea", and people to pile on and say "That's good, that's bad" and we're
    left with a lot of hot air and precious little code.

    So, Shlomi: Show me the code.

    --
    Andy Lester => andy@petdance.com => www.petdance.com => AIM:petdance
  • Mark Ethan Trostler at Sep 16, 2005 at 4:35 pm
    Alls you need to do is call:
    ($tot, $failedtests) = Test::Harness::_run_all_tests(@tests);
    instead of 'run_tests' to get at the '$tot' & '$failedtest' hash refs
    (Data::Dumper it or look at the comments in Test::Harness) which has all
    the info you need to output whatever/however you want - I use it to
    XML-ize Test::Harness output instead of the standard format.
    This also avoids the call to '_show_results' (or you can call it
    yourself later) so you can output whatever/however you want.
    Mark

    Andy Lester wrote:
    On Fri, Sep 16, 2005 at 11:35:05AM -0400, David Golden (david@hyperbolic.net) wrote:

    I think a polite question is wonderful (with potential answers ranging from
    "sure" to "hey, that's a cool idea, let's try a merge instead of a fork").

    Sure, it's a polite question, but an unnecessary one. He can do
    whatever he likes with the source.

    Just color me skeptical. As soon as there's something tangible for me
    to say "Hey, let's try a merge instead of a fork" about.

    Email lists make it easy for people to say "hey I've got this great
    idea", and people to pile on and say "That's good, that's bad" and we're
    left with a lot of hot air and precious little code.

    So, Shlomi: Show me the code.
  • Shlomi Fish at Sep 16, 2005 at 5:47 pm

    On Friday 16 September 2005 19:34, Mark Ethan Trostler wrote:
    Alls you need to do is call:
    ($tot, $failedtests) = Test::Harness::_run_all_tests(@tests);
    instead of 'run_tests' to get at the '$tot' & '$failedtest' hash refs
    (Data::Dumper it or look at the comments in Test::Harness) which has all
    the info you need to output whatever/however you want - I use it to
    XML-ize Test::Harness output instead of the standard format.
    This also avoids the call to '_show_results' (or you can call it
    yourself later) so you can output whatever/however you want.
    Hmmm... I've inspected the Test::Harness source now. While one can indeed do
    what you said, if I want to emulate the functionality of _show_results in its
    entirety, except for a small difference, then I'll have to duplicate a lot of
    code. That's Not Good<tm>.

    So I think a spin-off of Test::Harness which will facilitate doing that is
    still in order.

    Regards,

    Shlomi Fish

    Mark

    Andy Lester wrote:
    On Fri, Sep 16, 2005 at 11:35:05AM -0400, David Golden
    (david@hyperbolic.net) wrote:
    I think a polite question is wonderful (with potential answers ranging
    from "sure" to "hey, that's a cool idea, let's try a merge instead of a
    fork").
    Sure, it's a polite question, but an unnecessary one. He can do
    whatever he likes with the source.

    Just color me skeptical. As soon as there's something tangible for me
    to say "Hey, let's try a merge instead of a fork" about.

    Email lists make it easy for people to say "hey I've got this great
    idea", and people to pile on and say "That's good, that's bad" and we're
    left with a lot of hot air and precious little code.

    So, Shlomi: Show me the code.
    --

    ---------------------------------------------------------------------
    Shlomi Fish shlomif@iglu.org.il
    Homepage: http://www.shlomifish.org/

    95% of the programmers consider 95% of the code they did not write, in the
    bottom 5%.
  • Tels at Sep 16, 2005 at 5:58 pm
    -----BEGIN PGP SIGNED MESSAGE-----

    Moin,
    On Friday 16 September 2005 19:44, Shlomi Fish wrote:
    On Friday 16 September 2005 19:34, Mark Ethan Trostler wrote:
    Alls you need to do is call:
    ($tot, $failedtests) = Test::Harness::_run_all_tests(@tests);
    instead of 'run_tests' to get at the '$tot' & '$failedtest' hash refs
    (Data::Dumper it or look at the comments in Test::Harness) which has
    all the info you need to output whatever/however you want - I use it
    to XML-ize Test::Harness output instead of the standard format. This
    also avoids the call to '_show_results' (or you can call it yourself
    later) so you can output whatever/however you want.
    Hmmm... I've inspected the Test::Harness source now. While one can
    indeed do what you said, if I want to emulate the functionality of
    _show_results in its entirety, except for a small difference, then I'll
    have to duplicate a lot of code. That's Not Good<tm>.

    So I think a spin-off of Test::Harness which will facilitate doing that
    is still in order.
    Why not fix Test::Harness instead of re-inventing it entirely?

    Best wishes,

    Tels

    - --
    Signed on Fri Sep 16 19:57:37 2005 with key 0x93B84C15.
    Visit my photo gallery at http://bloodgate.com/photos/
    PGP key on http://bloodgate.com/tels.asc or per email.

    "The campaign should combat the messages of pornography by putting signs
    on buses saying sex with children is not OK." -- Mary Anne Layden in
    ttp://tinyurl.com/6a9cy
  • Ovid at Sep 16, 2005 at 9:04 pm

    --- Tels wrote:

    So I think a spin-off of Test::Harness which will facilitate doing that
    is still in order.
    Why not fix Test::Harness instead of re-inventing it entirely?
    That's my thought. It's been known for a long time that Test::Harness
    works well, but only for the specific task it's been designed for.
    There's been a lot of discussion about improving/extending it. This is
    a much better solution than making a fork for a feature that's likely
    not compelling enough for folks to make the switch.

    Don't get me wrong. I also want color highlighting of test code.
    However, there's a lot more stuff I would like to do with the test
    output (imagine a Wx extension that provides the red/green color bars
    that JUnit provides). By fixing Test::Harness, we get a more general
    case solution and everybody wins.

    Cheers,
    Ovid

    --
    If this message is a response to a question on a mailing list, please send
    follow up questions to the list.

    Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/
  • Shlomi Fish at Sep 17, 2005 at 7:11 am
    Hi Tels!

    [I'm removing some CCed people]
    On Friday 16 September 2005 20:58, Tels wrote:
    Moin,
    On Friday 16 September 2005 19:44, Shlomi Fish wrote:
    On Friday 16 September 2005 19:34, Mark Ethan Trostler wrote:
    Alls you need to do is call:
    ($tot, $failedtests) = Test::Harness::_run_all_tests(@tests);
    instead of 'run_tests' to get at the '$tot' & '$failedtest' hash refs
    (Data::Dumper it or look at the comments in Test::Harness) which has
    all the info you need to output whatever/however you want - I use it
    to XML-ize Test::Harness output instead of the standard format. This
    also avoids the call to '_show_results' (or you can call it yourself
    later) so you can output whatever/however you want.
    Hmmm... I've inspected the Test::Harness source now. While one can
    indeed do what you said, if I want to emulate the functionality of
    _show_results in its entirety, except for a small difference, then I'll
    have to duplicate a lot of code. That's Not Good<tm>.

    So I think a spin-off of Test::Harness which will facilitate doing that
    is still in order.
    Why not fix Test::Harness instead of re-inventing it entirely?
    Well, first of all the plan is to start from the original Test::Harness, and
    gradually improve it. It won't be a rewrite, it would be an evolutionary
    process.

    As to why it has to be done: Test::Harness uses procedural interfaces and
    monlithic functions. Thus overriding the various parts is very hard. I'd
    rather have an improved version (derived from the original) that has an OO
    interface, that can be customized using @ISA.

    Regards,

    Shlomi Fish

    ---------------------------------------------------------------------
    Shlomi Fish shlomif@iglu.org.il
    Homepage: http://www.shlomifish.org/

    95% of the programmers consider 95% of the code they did not write, in the
    bottom 5%.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupqa @
categoriesperl
postedSep 5, '05 at 9:44a
activeSep 17, '05 at 7:11a
posts14
users9
websiteqa.perl.org

People

Translate

site design / logo © 2021 Grokbase