Author: jkeenan
Date: Thu Oct  4 18:31:32 2007
New Revision: 21858

Added:
   branches/reconfigure/t/configure/050-fatal_step.t   (contents, props changed)
Modified:
   branches/reconfigure/MANIFEST
   branches/reconfigure/lib/Parrot/Configure.pm

Log:
1.  In Parrot::Configure, add a get_list_of_steps() method to return the list
of configuration step names found -- once you have used add_step() or
add_steps() -- in the Parrot::Configure object's 'list_of_steps' element.
2.  Implement --fatal-step (sans '=some::step') to require any configuration
step, upon individual step failure, to cause configuration to halt.
3.  Provide new test file to test --fatal-step.


Modified: branches/reconfigure/MANIFEST
==============================================================================
--- branches/reconfigure/MANIFEST       (original)
+++ branches/reconfigure/MANIFEST       Thu Oct  4 18:31:32 2007
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Thu Oct  4 03:03:47 2007 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Fri Oct  5 01:23:43 2007 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -2961,6 +2961,7 @@
 t/configure/047-inter.t                                     []
 t/configure/048-return_undef.t                              []
 t/configure/049-run_single_step.t                           []
+t/configure/050-fatal_step.t                                []
 t/configure/101-init_manifest.01.t                          []
 t/configure/101-init_manifest.02.t                          []
 t/configure/102-init_defaults.01.t                          []

Modified: branches/reconfigure/lib/Parrot/Configure.pm
==============================================================================
--- branches/reconfigure/lib/Parrot/Configure.pm        (original)
+++ branches/reconfigure/lib/Parrot/Configure.pm        Thu Oct  4 18:31:32 2007
@@ -36,7 +36,6 @@
 
 use strict;
 use warnings;
-use Data::Dumper;
 
 use lib qw(config);
 use Carp qw(carp croak);
@@ -123,7 +122,7 @@
 
 Provides a list of registered steps, where each step is represented by an
 L<Parrot::Configure::Task> object.  Steps are returned in the order in which
-they were registered in.
+they were registered.
 
 Accepts no arguments and returns a list in list context or an arrayref in
 scalar context.
@@ -136,6 +135,30 @@
     return wantarray ? @{ $conf->{steps} } : $conf->{steps};
 }
 
+=item * C<get_list_of_steps()>
+
+Provides a list of the B<names> of registered steps.
+
+C<steps()>, in contrast, provides a list of registered step B<objects>, of
+which the B<step name> is just a small part.  Step names are returned in the
+order in which their corresponding step objects were registered.
+
+Accepts no arguments and returns a list in list context or an arrayref in
+scalar context.
+
+B<Note:> The list of step names returned by C<get_list_of_steps()> will be the
+same as that returned by C<Parrot::Configure::Step::List::get_steps_list()>
+B<provided> that you have not used C<add_step()> or C<add_steps()> to add any
+configuration tasks other than those named in
+C<Parrot::Configure::Step::List::get_steps_list()>.
+
+=cut
+
+sub get_list_of_steps {
+    my $conf = shift;
+    return wantarray ? @{ $conf->{list_of_steps} } : $conf->{list_of_steps};
+}
+
 =item * C<add_step()>
 
 Registers a new step and any parameters that should be passed to it.  The
@@ -152,8 +175,8 @@
 
     push @{ $conf->{steps} },
         Parrot::Configure::Task->new(
-        step   => $step,
-        params => [EMAIL PROTECTED],
+            step   => $step,
+            params => [EMAIL PROTECTED],
         );
 
     return 1;
@@ -245,7 +268,8 @@
             $/x
         ) {
             %steps_to_die_for = map {$_, 1} (split /,/, $fatal_step);
-#            print STDERR Dumper \%steps_to_die_for;
+        } elsif ( $fatal_step == 1 ) {
+            %steps_to_die_for = map {$_, 1} @{ $conf->{list_of_steps} };
         } else {
             die "Argument to 'fatal-step' option must be comma-delimited 
string of valid configuration steps";
         }

Added: branches/reconfigure/t/configure/050-fatal_step.t
==============================================================================
--- (empty file)
+++ branches/reconfigure/t/configure/050-fatal_step.t   Thu Oct  4 18:31:32 2007
@@ -0,0 +1,91 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 050-fatal_step.t
+
+use strict;
+use warnings;
+
+use Test::More tests =>  6;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use Parrot::Configure;
+use Parrot::Configure::Options qw( process_options );
+use Parrot::Configure::Step::List qw( get_steps_list );
+use Parrot::IO::Capture::Mini;
+
+$| = 1;
+is($|, 1, "output autoflush is set");
+
+my $args = process_options( {
+    argv    => [ q{--fatal-step} ],
+    mode    => q{configure},
+} );
+ok(defined $args, "process_options returned successfully");
+my %args = %$args;
+
+my $conf = Parrot::Configure->new;
+ok(defined $conf, "Parrot::Configure->new() returned okay");
+
+my $first_step = q{init::zeta};
+my $description = 'Determining if your computer does zeta';
+
+$conf->add_steps( $first_step, get_steps_list() );
+
+$conf->options->set(%args);
+is($conf->options->{c}->{debugging}, 1,
+    "command-line option '--debugging' has been stored in object");
+
+my $rv;
+my (@lines, @errlines);
+{
+    my ($tie, $errtie);
+    $tie = tie *STDOUT, "Parrot::IO::Capture::Mini"
+        or croak "Unable to tie";
+    $errtie = tie *STDERR, "Parrot::IO::Capture::Mini"
+        or croak "Unable to tie";
+    $rv = $conf->runsteps;
+    @lines = $tie->READLINE;
+    @errlines = $errtie->READLINE;
+}
+untie *STDOUT;
+untie *STDERR;
+
+ok(! defined $rv, "runsteps returned undefined value as expected");
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+050-fatal_step.t - see what happens when C<--fatal-step> is set for all 
configuration steps
+
+=head1 SYNOPSIS
+
+    % prove t/configure/050-fatal_step.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file examine what happens when your configuration step
+module returns something other than the object but has some other defined
+result method.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+Parrot::Configure, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Reply via email to