Please review attached patch, which refactors Parrot configuration step auto::env slightly and provides 3 test files.
Index: MANIFEST =================================================================== --- MANIFEST (revision 22786) +++ MANIFEST (working copy) @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Sat Nov 10 01:52:43 2007 UT +# generated by tools/dev/mk_manifest_and_skip.pl Sat Nov 10 03:36:54 2007 UT # # See tools/dev/install_files.pl for documentation on the # format of this file. @@ -3096,7 +3096,9 @@ t/configure/139-auto_signal-01.t [] t/configure/140-auto_socklen_t-01.t [] t/configure/140-auto_socklen_t-02.t [] -t/configure/141-auto_env.t [] +t/configure/141-auto_env-01.t [] +t/configure/141-auto_env-02.t [] +t/configure/141-auto_env-03.t [] t/configure/142-auto_aio.t [] t/configure/143-auto_gmp.t [] t/configure/144-auto_readline.t [] Index: t/configure/141-auto_env-01.t =================================================================== --- t/configure/141-auto_env-01.t (revision 0) +++ t/configure/141-auto_env-01.t (revision 0) @@ -0,0 +1,77 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 141-auto_env-01.t + +use strict; +use warnings; +use Test::More tests => 12; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::env'); +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 ($task, $step_name, @step_params, $step, $ret); +my $pkg = q{auto::env}; + +$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"); + +ok($step->runstep($conf), "runstep() returned true value"); + +pass("Keep Devel::Cover happy"); +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +141-auto_env-01.t - test config::auto::env + +=head1 SYNOPSIS + + % prove t/configure/141-auto_env-01.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test subroutines found in config::auto::env in +its most ordinary usage. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::env, 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/141-auto_env-01.t ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Index: t/configure/141-auto_env.t =================================================================== --- t/configure/141-auto_env.t (revision 22786) +++ t/configure/141-auto_env.t (working copy) @@ -1,54 +0,0 @@ -#! perl -# Copyright (C) 2007, The Perl Foundation. -# $Id$ -# 141-auto_env.t - -use strict; -use warnings; -use Test::More tests => 2; -use Carp; -use lib qw( lib ); -use_ok('config::auto::env'); - -=for hints_for_testing The documentation for this package is skimpy; -please try to improve it, e.g., by explaining what 'setenv' and -'unsetenv' are. Try to cover all branches and conditions. 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 - -141-auto_env.t - test config::auto::env - -=head1 SYNOPSIS - - % prove t/configure/141-auto_env.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::env. - -=head1 AUTHOR - -James E Keenan - -=head1 SEE ALSO - -config::auto::env, F<Configure.pl>. - -=cut - -# Local Variables: -# mode: cperl -# cperl-indent-level: 4 -# fill-column: 100 -# End: -# vim: expandtab shiftwidth=4: Index: t/configure/141-auto_env-02.t =================================================================== --- t/configure/141-auto_env-02.t (revision 0) +++ t/configure/141-auto_env-02.t (revision 0) @@ -0,0 +1,98 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 141-auto_env-02.t + +use strict; +use warnings; +use Test::More tests => 15; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::env'); +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 ($task, $step_name, @step_params, $step, $ret); +my $pkg = q{auto::env}; + +$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"); + +my ($setenv, $unsetenv); + +$setenv = 1; +$unsetenv = 1; +$step->_evaluate_env($conf, $setenv, $unsetenv); +is($step->result(), q{both}, "Got expected result"); + +$setenv = 1; +$unsetenv = 0; +$step->_evaluate_env($conf, $setenv, $unsetenv); +is($step->result(), q{setenv}, "Got expected result"); + +$setenv = 0; +$unsetenv = 1; +$step->_evaluate_env($conf, $setenv, $unsetenv); +is($step->result(), q{unsetenv}, "Got expected result"); + +$setenv = 0; +$unsetenv = 0; +$step->_evaluate_env($conf, $setenv, $unsetenv); +is($step->result(), q{no}, "Got expected result"); + +pass("Keep Devel::Cover happy"); +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +141-auto_env-02.t - test config::auto::env + +=head1 SYNOPSIS + + % prove t/configure/141-auto_env-02.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test config::auto::env::_evaluate_env(), an +internal subroutine, in the various permutations of having or lacking +C<setenv> and C<unsetenv>. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::env, 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/141-auto_env-02.t ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Index: t/configure/141-auto_env-03.t =================================================================== --- t/configure/141-auto_env-03.t (revision 0) +++ t/configure/141-auto_env-03.t (revision 0) @@ -0,0 +1,121 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 141-auto_env-03.t + +use strict; +use warnings; +use Test::More tests => 19; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::env'); +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( test_step_thru_runstep); +use Parrot::IO::Capture::Mini; + +my $args = process_options( { + argv => [ q{--verbose} ], + mode => q{configure}, +} ); + +my $conf = Parrot::Configure->new(); + +test_step_thru_runstep($conf, q{init::defaults}, $args); + +my ($task, $step_name, @step_params, $step, $ret); +my $pkg = q{auto::env}; + +$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"); + +my ($setenv, $unsetenv); + +{ + my $tie_out = tie *STDOUT, "Parrot::IO::Capture::Mini" + or croak "Unable to tie"; + $setenv = 1; + $unsetenv = 1; + $step->_evaluate_env($conf, $setenv, $unsetenv); + like($tie_out->READLINE, qr/both/, "Got expected verbose output"); + is($step->result(), q{both}, "Got expected result"); +} +untie *STDOUT; + +{ + my $tie_out = tie *STDOUT, "Parrot::IO::Capture::Mini" + or croak "Unable to tie"; + $setenv = 1; + $unsetenv = 0; + $step->_evaluate_env($conf, $setenv, $unsetenv); + like($tie_out->READLINE, qr/setenv/, "Got expected verbose output"); + is($step->result(), q{setenv}, "Got expected result"); +} +untie *STDOUT; + +{ + my $tie_out = tie *STDOUT, "Parrot::IO::Capture::Mini" + or croak "Unable to tie"; + $setenv = 0; + $unsetenv = 1; + $step->_evaluate_env($conf, $setenv, $unsetenv); + like($tie_out->READLINE, qr/unsetenv/, "Got expected verbose output"); + is($step->result(), q{unsetenv}, "Got expected result"); +} +untie *STDOUT; + +{ + my $tie_out = tie *STDOUT, "Parrot::IO::Capture::Mini" + or croak "Unable to tie"; + $setenv = 0; + $unsetenv = 0; + $step->_evaluate_env($conf, $setenv, $unsetenv); + like($tie_out->READLINE, qr/no/, "Got expected verbose output"); + is($step->result(), q{no}, "Got expected result"); +} +untie *STDOUT; + +pass("Keep Devel::Cover happy"); +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +141-auto_env-03.t - test config::auto::env + +=head1 SYNOPSIS + + % prove t/configure/141-auto_env-03.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test config::auto::env in verbose mode. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::env, 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/141-auto_env-03.t ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Index: config/auto/env.pm =================================================================== --- config/auto/env.pm (revision 22786) +++ config/auto/env.pm (working copy) @@ -9,6 +9,10 @@ Determining if the C library has C<setenv()> and C<unsetenv()>. +More information about these functions can be found at +L<http://www.gnu.org/software/libc/manual/html_node/Environment-Access.html>, +among other locations. + =cut package auto::env; @@ -32,8 +36,6 @@ sub runstep { my ( $self, $conf ) = ( shift, shift ); - my $verbose = $conf->options->get('verbose'); - my ( $setenv, $unsetenv ) = ( 0, 0 ); cc_gen('config/auto/env/test_setenv.in'); @@ -49,6 +51,14 @@ } cc_clean(); + $self->_evaluate_env($conf, $setenv, $unsetenv); + + return 1; +} + +sub _evaluate_env { + my ($self, $conf, $setenv, $unsetenv) = @_; + my $verbose = $conf->options->get('verbose'); $conf->data->set( setenv => $setenv, unsetenv => $unsetenv @@ -70,8 +80,6 @@ print " (no) " if $verbose; $self->set_result('no'); } - - return 1; } 1;