The patch attached provides a refactoring of configuration step class auto::byteorder along the same lines as other recent refactorings of auto::* config classes, i.e., the code handling the C probe is refactored into one internal subroutine, while everything that follows is refactored into an internal method which is directly addressed in the 3 new test files found in the patch.
Will apply in 2-3 days unless someone objects. Thank you very much. kid51
Index: MANIFEST =================================================================== --- MANIFEST (revision 22607) +++ MANIFEST (working copy) @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Mon Oct 29 20:02:14 2007 UT +# generated by tools/dev/mk_manifest_and_skip.pl Tue Oct 30 02:49:13 2007 UT # # See tools/dev/install_files.pl for documentation on the # format of this file. @@ -3039,7 +3039,9 @@ t/configure/124-auto_alignptrs-01.t [] t/configure/125-auto_headers-01.t [] t/configure/126-auto_sizes-01.t [] -t/configure/127-auto_byteorder.t [] +t/configure/127-auto_byteorder-01.t [] +t/configure/127-auto_byteorder-02.t [] +t/configure/127-auto_byteorder-03.t [] t/configure/128-auto_va_ptr.t [] t/configure/129-auto_pack.t [] t/configure/130-auto_format.t [] Index: t/configure/127-auto_byteorder-02.t =================================================================== --- t/configure/127-auto_byteorder-02.t (revision 0) +++ t/configure/127-auto_byteorder-02.t (revision 0) @@ -0,0 +1,92 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 127-auto_byteorder-02.t + +use strict; +use warnings; +use Test::More tests => 18; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::byteorder'); +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( test_step_thru_runstep); + +my $args = process_options( + { + argv => [ ], + mode => q{configure}, + } +); + +my $conf = Parrot::Configure->new; + +test_step_thru_runstep( $conf, q{init::defaults}, $args ); + +my $pkg = q{auto::byteorder}; + +$conf->add_steps($pkg); +$conf->options->set( %{$args} ); + +my ( $task, $step_name, @step_params, $step); +$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" ); + +my ($byteorder, $rv); + +$byteorder = q{8765}; +$rv = $step->_evaluate_byteorder($conf, $byteorder); +ok( $rv, "_evaluate_byteorder() returned true value as expected"); +is( $conf->data->get( 'byteorder'), $byteorder, "Got expected byteorder"); +ok( $conf->data->get( 'bigendian' ), "Not big-endian"); +is( $step->result, 'big-endian', "Indeed, big-endian"); + +$byteorder = q{4321}; +$rv = $step->_evaluate_byteorder($conf, $byteorder); +ok( $rv, "_evaluate_byteorder() returned true value as expected"); +is( $conf->data->get( 'byteorder'), $byteorder, "Got expected byteorder"); +ok( $conf->data->get( 'bigendian' ), "Not big-endian"); +is( $step->result, 'big-endian', "Indeed, big-endian"); + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +127-auto_byteorder-02.t - test config::auto::byteorder + +=head1 SYNOPSIS + + % prove t/configure/127-auto_byteorder-02.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test subroutines exported by config::auto::byteorder. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::byteorder, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Property changes on: t/configure/127-auto_byteorder-02.t ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Index: t/configure/127-auto_byteorder-03.t =================================================================== --- t/configure/127-auto_byteorder-03.t (revision 0) +++ t/configure/127-auto_byteorder-03.t (revision 0) @@ -0,0 +1,86 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 127-auto_byteorder-03.t + +use strict; +use warnings; +use Test::More qw(no_plan); # tests => 18; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::byteorder'); +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( test_step_thru_runstep); + +my $args = process_options( + { + argv => [ ], + mode => q{configure}, + } +); + +my $conf = Parrot::Configure->new; + +test_step_thru_runstep( $conf, q{init::defaults}, $args ); + +my $pkg = q{auto::byteorder}; + +$conf->add_steps($pkg); +$conf->options->set( %{$args} ); + +my ( $task, $step_name, @step_params, $step); +$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" ); + +my ($byteorder, $rv); + +$byteorder = q{foobar}; +eval { + $rv = $step->_evaluate_byteorder($conf, $byteorder); +}; +like($@, + qr/Unsupported byte-order \[$byteorder\]!/, + "Got error message expected with bad byte-order"); + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +127-auto_byteorder-03.t - test config::auto::byteorder + +=head1 SYNOPSIS + + % prove t/configure/127-auto_byteorder-03.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test subroutines exported by config::auto::byteorder. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::byteorder, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Property changes on: t/configure/127-auto_byteorder-03.t ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Index: t/configure/127-auto_byteorder-01.t =================================================================== --- t/configure/127-auto_byteorder-01.t (revision 0) +++ t/configure/127-auto_byteorder-01.t (revision 0) @@ -0,0 +1,83 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 127-auto_byteorder-01.t + +use strict; +use warnings; +use Test::More tests => 14; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::byteorder'); +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( test_step_thru_runstep); + +my $args = process_options( + { + argv => [ ], + mode => q{configure}, + } +); + +my $conf = Parrot::Configure->new; + +test_step_thru_runstep( $conf, q{init::defaults}, $args ); + +my $pkg = q{auto::byteorder}; + +$conf->add_steps($pkg); +$conf->options->set( %{$args} ); + +my ( $task, $step_name, @step_params, $step); +$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" ); + +my $byteorder = q{1234}; +my $rv = $step->_evaluate_byteorder($conf, $byteorder); +ok( $rv, "_evaluate_byteorder() returned true value as expected"); +is( $conf->data->get( 'byteorder'), $byteorder, "Got expected byteorder"); +ok( ! $conf->data->get( 'bigendian' ), "Not big-endian"); +is( $step->result, 'little-endian', "Rather, little-endian"); + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +127-auto_byteorder-01.t - test config::auto::byteorder + +=head1 SYNOPSIS + + % prove t/configure/127-auto_byteorder-01.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test subroutines exported by config::auto::byteorder. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::byteorder, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Property changes on: t/configure/127-auto_byteorder-01.t ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Index: t/configure/127-auto_byteorder.t =================================================================== --- t/configure/127-auto_byteorder.t (revision 22607) +++ t/configure/127-auto_byteorder.t (working copy) @@ -1,52 +0,0 @@ -#! perl -# Copyright (C) 2007, The Perl Foundation. -# $Id$ -# 127-auto_byteorder.t - -use strict; -use warnings; -use Test::More tests => 2; -use Carp; -use lib qw( lib ); -use_ok('config::auto::byteorder'); - -=for hints_for_testing Check latest reports of Parrot configuration -tools testing coverage to see where your time available for writing -tests is spent. - -=cut - -pass("Completed all tests in $0"); - -################### DOCUMENTATION ################### - -=head1 NAME - -127-auto_byteorder.t - test config::auto::byteorder - -=head1 SYNOPSIS - - % prove t/configure/127-auto_byteorder.t - -=head1 DESCRIPTION - -The files in this directory test functionality used by F<Configure.pl>. - -The tests in this file test subroutines exported by config::auto::byteorder. - -=head1 AUTHOR - -James E Keenan - -=head1 SEE ALSO - -config::auto::byteorder, F<Configure.pl>. - -=cut - -# Local Variables: -# mode: cperl -# cperl-indent-level: 4 -# fill-column: 100 -# End: -# vim: expandtab shiftwidth=4: Index: config/auto/byteorder.pm =================================================================== --- config/auto/byteorder.pm (revision 22607) +++ config/auto/byteorder.pm (working copy) @@ -32,13 +32,25 @@ sub runstep { my ( $self, $conf ) = @_; + my $byteorder = _probe_for_byteorder(); + + $self->_evaluate_byteorder($conf, $byteorder); + + return 1; +} + +sub _probe_for_byteorder { cc_gen('config/auto/byteorder/test_c.in'); cc_build(); - my $byteorder = cc_run() or die "Can't run the byteorder testing program: $!"; + my $byteorder = cc_run() + or die "Can't run the byteorder testing program: $!"; cc_clean(); - chomp $byteorder; + return $byteorder; +} +sub _evaluate_byteorder { + my ($self, $conf, $byteorder) = @_; if ( $byteorder =~ /^1234/ ) { $conf->data->set( byteorder => $byteorder, @@ -56,7 +68,6 @@ else { die "Unsupported byte-order [$byteorder]!"; } - return 1; }