On Wednesday 05 September 2007 18:02:26 James Keenan via RT wrote:

> chromatic wrote:

> > That looks reasonable, but why does the code use prove in the first
> > place, and not Test::Harness::runtests()?
>
> And why not?

For the same reason to use Perl's built-in file manipulation routines instead 
of calling shell commands -- they're there, they work, they're more portable, 
and they're more efficient.

> From 'perldoc Test::Harness':
>
> "STOP! If all you want to do is write a test script, consider using
> Test::Simple."

You're not writing a test script, you're running tests.

> ... and ...
>
> "The prove utility is a thin wrapper around Test::Harness."
>
> From these I infer:  (1) Cet. par., use Test::Simple or Test::More.  (2)
>  When that's not appropriate, use 'prove'.
>
> At YAPC::NA::2004 in Buffalo, Andy Lester gave a lightning talk which
> boiled down to:  "Use 'prove'."
>
> Naturally, I did what Andy told me.

Andy wasn't talking about this!

> I've done a lot of testing since then, have written a lot of tests, and
> have given talks on my adventures in testing.  In each of those talks I
> have repeated the message:  use 'prove'.
>
> No one has ever contradicted me on that.  In particular, no one has ever
> said, "You should be using Test::Harness::runtests() instead."  In fact,
> until I ran the perldoc just now, I mostly associated runtests() with
> discussion of the upcoming Test::Harness 3.0 on the qa list.

I'm not saying "Hey, instead of using prove at the command line, use 
perl -MTest::Harness -e 'runtests(qw( your test files here ))".  I'm saying 
that this reminds me of the people who show up on PerlMonks saying, "Hey, I 
want to call a CGI program from another CGI program and not through GET or 
POST or something like that but run the program directly" and all of us slap 
our heads and say "You know, if you put the really heavy lifting code in a 
module, you could take advantage of Perl's standard mechanism of code re-use 
and not have to do the really clever work of trying to make what you think 
you wanted to work actually work."

> Of course, the other Andy (or one of the other Andys) -- Andy Dougherty
> -- has the knack of finding bugs in my tests that no one else does.  So
> I'll give his patch serious consideration.

Hey, if it's worked so far, great.  All I'm saying is that I think it's 
suboptimal in the long run now that I've looked at the code, and I think it 
may be possible to simplify the code and avoid problems in the future by 
rethinking the approach.

If all we need from prove is the ability to run tests, that's not a feature of 
prove at all -- it comes from Test::Harness.  We can avoid all the fun of 
trying to find the right version of prove and launching the command and 
checking that it succeeded and giving warnings if it didn't.

> But if you think Test::Harness::runtests() is superior to 'prove' in
> this case ... well, as the first Andy would say, "Patches welcome."

Here you go!

-- c
=== lib/Parrot/Configure/Options/Test.pm
==================================================================
--- lib/Parrot/Configure/Options/Test.pm	(revision 5702)
+++ lib/Parrot/Configure/Options/Test.pm	(local)
@@ -1,14 +1,16 @@
-# Copyright (C) 2001-2006, The Perl Foundation.
+# Copyright (C) 2001-2007, The Perl Foundation.
 # $Id$
 package Parrot::Configure::Options::Test;
 use strict;
 use warnings;
 
-our @preconfiguration_tests = qw(
+use Test::Harness;
+
+our @preconfiguration_tests = map { glob } qw(
     t/configure/*.t
 );
 
-our @postconfiguration_tests = qw(
+our @postconfiguration_tests = map { glob } qw(
     t/postconfigure/*.t
     t/tools/pmc2cutils/*.t
     t/tools/ops2cutils/*.t
@@ -38,8 +40,7 @@
     my $self = shift;
     if ($self->{run_configure_tests}) {
         print "As you requested, we'll start with some tests of the configuration tools.\n\n";
-        system(qq{prove @preconfiguration_tests})
-            and die "Pre-configuration tests did not complete successfully; Configure.pl will not continue.";
+        runtests(@preconfiguration_tests);
         print <<"TEST";
 
 I just ran some tests to demonstrate that
@@ -55,8 +56,7 @@
     if ($self->{run_build_tests}) {
         print "\n\n";
         print "As you requested, I will now run some tests of the build tools.\n\n";
-        system(qq{prove @postconfiguration_tests})
-            and die "Post-configuration and build tools tests did not complete successfully; running 'make' might be dubious.";
+        runtests(@postconfiguration_tests);
     }
     return 1;
 }

Reply via email to