There was code in several of the test files in the reconfigure/ branch which 
was repeated.  At 
the hackathon, David Adler refactored it into a subroutine which I then placed 
in new file 
Auxiliary.pm.  That file is contained in this patch along with a revised 
t/104-init_miniparrot.t 
and appropriate MANIFEST revisions.

Please review.  Thank you very much.
kid51
Index: MANIFEST
===================================================================
--- MANIFEST    (revision 19464)
+++ MANIFEST    (working copy)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Thu Jun 28 21:14:19 2007 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Fri Jun 29 14:51:05 2007 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -2862,6 +2862,7 @@
 t/configure/config_steps.t                                  []
 t/configure/data.t                                          []
 t/configure/step.t                                          []
+t/configure/testlib/Auxiliary.pm                            []
 t/configure/testlib/Make_VERSION_File.pm                    []
 t/configure/testlib/init/alpha.pm                           []
 t/configure/testlib/init/beta.pm                            []
Index: MANIFEST.SKIP
===================================================================
--- MANIFEST.SKIP       (revision 19464)
+++ MANIFEST.SKIP       (working copy)
@@ -1,6 +1,6 @@
 # ex: set ro:
 # $Id$
-# generated by tools/dev/mk_manifest_and_skip.pl Thu Jun 28 20:58:24 2007 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Fri Jun 29 14:51:05 2007 UT
 #
 # This file should contain a transcript of the svn:ignore properties
 # of the directories in the Parrot subversion repository. (Needed for
Index: t/configure/104-init_miniparrot.t
===================================================================
--- t/configure/104-init_miniparrot.t   (revision 19464)
+++ t/configure/104-init_miniparrot.t   (working copy)
@@ -7,20 +7,14 @@
 use warnings;
 use Test::More tests => 22;
 use Carp;
-use lib qw( . lib ../lib ../../lib );
+use lib qw( . lib ../lib ../../lib t/configure/testlib );
 use_ok('config::init::defaults');
 use_ok('config::init::miniparrot');
 use Parrot::BuildUtil;
 use Parrot::Configure;
 use Parrot::Configure::Options qw( process_options );
+use Auxiliary qw( test_step_thru_runstep);
 
-=for hints_for_testing This file ought to test what happens when you
-first create a Parrot::Configure object, populate it with default
-settings as in init::defaults, then override those settings per
-init::miniparrot.
-
-=cut
-
 my $parrot_version = Parrot::BuildUtil::parrot_version();
 my $args = process_options( {
     argv            => [ q{--miniparrot} ],
@@ -31,23 +25,8 @@
 
 my $conf = Parrot::Configure->new;
 
-my ($pkg, $task, $step_name, @step_params, $step, $ret);
+test_step_thru_runstep($conf, q{init::defaults}, $args, 0);
 
-$pkg = q{init::defaults};
-$conf->add_steps($pkg);
-$conf->options->set(%{$args});
-
-$task = $conf->steps->[0];
-$step_name   = $task->step;
[EMAIL PROTECTED] = @{ $task->params };
-
-$step = $step_name->new();
-ok(defined $step, "$step_name constructor returned defined value");
-isa_ok($step, $step_name);
-ok($step->description(), "$step_name has description");
-$ret = $step->runstep($conf);
-ok(defined $ret, "$step_name runstep() returned defined value");
-
 is($conf->data->get('miniparrot'), undef,
     "miniparrot is not yet enabled");
 is($conf->data->get('jitarchname'), undef,
@@ -59,23 +38,8 @@
 is($conf->data->get('jitosname'), undef,
     "jitosname undef as expected");
 
+test_step_thru_runstep($conf, q{init::miniparrot}, $args, 1);
 
-$pkg = q{init::miniparrot};
-
-$conf->add_steps($pkg);
-$conf->options->set(%{$args});
-
-$task = $conf->steps->[1];
-$step_name   = $task->step;
[EMAIL PROTECTED] = @{ $task->params };
-
-$step = $step_name->new();
-ok(defined $step, "$step_name constructor returned defined value");
-isa_ok($step, $step_name);
-ok($step->description(), "$step_name has description");
-$ret = $step->runstep($conf);
-ok(defined $ret, "$step_name runstep() returned defined value");
-
 ok($conf->data->get('miniparrot'),
     "miniparrot is enabled");
 is($conf->data->get('jitarchname'), 'nojit',
Index: t/configure/testlib/Auxiliary.pm
===================================================================
--- t/configure/testlib/Auxiliary.pm    (revision 0)
+++ t/configure/testlib/Auxiliary.pm    (revision 0)
@@ -0,0 +1,89 @@
+# Copyright (C) 2007, The Perl Foundation.
+# $Id: GenerateCore.pm 17576 2007-03-17 22:50:07Z paultcochrane $
+package Auxiliary;
+use strict;
+use warnings;
+our ( @ISA, @EXPORT_OK );
[EMAIL PROTECTED]       = qw(Exporter);
[EMAIL PROTECTED] = qw(
+    test_step_thru_runstep
+);
+use Carp;
+*ok = *Test::More::ok;
+*isa_ok = *Test::More::isa_ok;
+use lib qw( . lib ../lib ../../lib );
+use Parrot::Configure;
+
+sub test_step_thru_runstep {
+    my ($conf, $pkg, $args, $stepnum) = @_;
+    my ($task, $step_name, @step_params, $step, $ret);
+    
+    $conf->add_steps($pkg);
+    $conf->options->set(%{$args});
+
+    $task = $conf->steps->[$stepnum];
+    $step_name   = $task->step;
+    @step_params = @{ $task->params };
+
+    $step = $step_name->new();
+    ok(defined $step, "$step_name constructor returned defined value");
+    isa_ok($step, $step_name);
+    ok($step->description(), "$step_name has description");
+    $ret = $step->runstep($conf);
+    ok(defined $ret, "$step_name runstep() returned defined value");
+}
+
+1;
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+Auxiliary - subroutines used in F<t/configure/*> tests
+
+=head1 SYNOPSIS
+
+    use lib qw( . lib ../lib ../../lib t/configure/testlib );
+    use Auxiliary qw( test_step_thru_runstep );
+
+    $parrot_version = Parrot::BuildUtil::parrot_version();
+    $args = process_options( {
+    argv            => [ ],
+    script          => $0,
+    parrot_version  => $parrot_version,
+    svnid           => '$Id: 105-init_hints.01.t 19432 2007-06-29 00:24:16Z 
jkeenan $',
+} );
+
+    $conf = Parrot::Configure->new;
+    test_step_thru_runstep($conf, q{init::defaults}, $args, 0);
+
+=head1 DESCRIPTION
+
+The subroutines in this package are used to simplify tests found in
+F<t/configure/>.
+
+So far, only one subroutine is available for export on demand:
+C<test_step_thru_runstep()>.  This subroutine takes as arguments the
+Parrot::Configure object, a string holding the name of the step to be run,
+hashref C<$args> which is the output of C<process_options()> and an integer
+which, so far, must be manually incremented between invocations of the
+subroutine.
+
+Each invocation of C<test_step_thru_runstep()> runs 4 tests.
+
+=head1 AUTHOR
+
+David H Adler and James E Keenan
+
+=head1 SEE ALSO
+
+F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Reply via email to