# New Ticket Created by James Keenan # Please include the string: [perl #42337] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=42337 >
This patch transfers one aspect of Configure.pl's functionality -- its listing of the steps in the configurati0n process -- out of that script and places it in a new package: lib/Parrot/Configure/Step/List.pm. Parrot::Configure::Step::List exports a single subroutine on demand: get_steps_list(). By placing this functionality in a subroutine exported by a class, we can write tests for it using Perl's standard testing apparatus. Accordingly, a test file is supplied as part of this patch: t/configure/03-steplist.t This is the third in a series of patches a number of Parrot hackers and I have submitted which refactor Configure.pl and the various Parrot::Configure::* classes. This refactoring is focused primarily on increasing the testability -- and, by extension, the long-term maintainability -- of Parrot's configuration code. Assuming that our refactoring is correct, the end result of the configuration process should not change in the least. (To confirm, do a 'diff' on lib/Parrot/Config/Generated.pm versus an unpatched version.) However, if in the future you are proposing revisions to functionality originally found in Configure.pl (e.g., adding a new configuration step), you may have to look in a new place to make such a revision. Assuming no objection, I will apply this patch to trunk in approximately three days. Thank you very much. kid51
Index: lib/Parrot/Configure/Step/List.pm =================================================================== --- lib/Parrot/Configure/Step/List.pm (revision 0) +++ lib/Parrot/Configure/Step/List.pm (revision 0) @@ -0,0 +1,130 @@ +# Copyright (C) 2001-2006, The Perl Foundation. +# $Id: List.pm 17903 2007-03-31 15:53:17Z jkeenan $ +package Parrot::Configure::Step::List; +use strict; +use warnings; +use base qw( Exporter ); +our @EXPORT_OK = qw( get_steps_list ); + +# EDIT HERE TO ADD NEW TESTS +my @steps = qw( + init::manifest + init::defaults + init::install + init::miniparrot + init::hints + init::headers + inter::progs + inter::make + inter::lex + inter::yacc + auto::gcc + auto::msvc + init::optimize + inter::shlibs + inter::libparrot + inter::charset + inter::encoding + inter::types + inter::ops + inter::pmc + auto::alignptrs + auto::headers + auto::sizes + auto::byteorder + auto::va_ptr + auto::pack + auto::format + auto::isreg + auto::jit + gen::cpu + auto::funcptr + auto::cgoto + auto::inline + auto::gc + auto::memalign + auto::signal + auto::socklen_t + auto::env + auto::aio + auto::gmp + auto::readline + auto::gdbm + auto::snprintf + auto::perldoc + auto::python + auto::m4 + auto::cpu + gen::icu + gen::revision + gen::config_h + gen::core_pmcs + gen::parrot_include + gen::languages + gen::makefiles + gen::platform + gen::config_pm +); + +sub get_steps_list {return @steps;} + +1; + +#################### DOCUMENTATION #################### + +=head1 NAME + +Parrot::Configure::Step::List - Get sequence of configuration steps + +=head1 SYNOPSIS + + use Parrot::Configure::Step::List qw( get_steps_list ); + + @steps = get_steps_list(); + +=head1 DESCRIPTION + +Parrot::Configure::Step::List exports on demand a single subroutine, +C<get_steps_list()>. This subroutine returns a list of Parrot's configuration +steps in the order in which they are to be executed. To change the order in +which the steps are executed, edit C<@steps> inside this module. + +=head1 SUBROUTINE + +=head2 C<get_steps_list()> + +=over 4 + +=item * Purpose + +Provide Parrot configuration steps in their order of execution. + +=item * Arguments + +None. + +=item * Return Value + +List holding strings representing the configuration steps. + +=item * Comment + +=back + +=head1 NOTES + +The functionality in this package was transferred from F<Configure.pl> by Jim +Keenan. + +=head1 SEE ALSO + +F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Property changes on: lib/Parrot/Configure/Step/List.pm ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Index: MANIFEST =================================================================== --- MANIFEST (revision 18031) +++ MANIFEST (working copy) @@ -2223,6 +2223,7 @@ lib/Parrot/Configure/Options.pm [devel] lib/Parrot/Configure/Step.pm [devel] lib/Parrot/Configure/Step/Base.pm [devel] +lib/Parrot/Configure/Step/List.pm [devel] lib/Parrot/Distribution.pm [devel] lib/Parrot/Docs/Directory.pm [devel] lib/Parrot/Docs/File.pm [devel] @@ -2766,6 +2767,7 @@ t/compilers/tge/parser.t [] t/configure/01-options.t [] t/configure/02-messages.t [] +t/configure/03-steplist.t [] t/configure/base.t [] t/configure/config_steps.t [] t/configure/configure.t [] Index: Configure.pl =================================================================== --- Configure.pl (revision 18031) +++ Configure.pl (working copy) @@ -267,6 +267,7 @@ print_introduction print_conclusion ); +use Parrot::Configure::Step::List qw( get_steps_list ); # These globals are accessed in config/init/defaults.pm our $parrot_version = Parrot::BuildUtil::parrot_version(); @@ -364,7 +365,10 @@ no warnings qw(once); $Parrot::Configure::Step::conf = $conf; } -$conf->add_steps(@steps); + +# from Parrot::Configure::Step::List +$conf->add_steps(get_steps_list()); + $conf->options->set(%args); if ( exists $args{step} ) { Index: t/configure/03-steplist.t =================================================================== --- t/configure/03-steplist.t (revision 0) +++ t/configure/03-steplist.t (revision 0) @@ -0,0 +1,63 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id: 03-steplist.t 17800 2007-03-28 01:19:35Z jkeenan $ +# 03-steplist.t + +use strict; +use warnings; + +BEGIN { + use FindBin qw($Bin); + use Cwd qw(cwd realpath); + realpath($Bin) =~ m{^(.*\/parrot)\/[^/]*\/[^/]*\/[^/]*$}; + our $topdir = $1; + if ( defined $topdir ) { + print "\nOK: Parrot top directory located\n"; + } + else { + $topdir = realpath($Bin) . "/../.."; + } + unshift @INC, qq{$topdir/lib}; +} +use Test::More qw(no_plan); # tests => 10; +use Carp; +use_ok('Parrot::Configure::Step::List', qw| + get_steps_list +| ); + +my @steps; +ok(@steps = get_steps_list(), "non-zero number of steps located"); +my $badsteps = 0; +foreach my $s (@steps) { + $badsteps++ unless $s =~ /^(init|inter|auto|gen)::\w+$/; +} +is($badsteps, 0, "no bad entries found in [EMAIL PROTECTED]"); + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +03-steplist.t - test Parrot::Configure::Step::List + +=head1 SYNOPSIS + + % prove t/configure/03-steplist.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test subroutines exported by +Parrot::Configure::Step::List. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +Parrot::Configure::Step::List, F<Configure.pl>. + +=cut Property changes on: t/configure/03-steplist.t ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native