The patch attached refactors configuration step class auto::snprintf along the same lines as other classes recently refactored, i.e., the C probes are isolated in a subroutine; all subsequent code is isolated in an internal method. We can then mock the return value of _probe_for_snprintf() and fully test _evaluate_snprintf(). 3 test files submitted, replacing one placeholder test file. MANIFEST updated.
Will apply in 2-3 days if there is no objection. kid51
Index: MANIFEST =================================================================== --- MANIFEST (revision 22653) +++ MANIFEST (working copy) @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Wed Oct 31 23:05:08 2007 UT +# generated by tools/dev/mk_manifest_and_skip.pl Fri Nov 2 00:12:11 2007 UT # # See tools/dev/install_files.pl for documentation on the # format of this file. @@ -3082,7 +3082,9 @@ t/configure/143-auto_gmp.t [] t/configure/144-auto_readline.t [] t/configure/145-auto_gdbm.t [] -t/configure/146-auto_snprintf.t [] +t/configure/146-auto_snprintf-01.t [] +t/configure/146-auto_snprintf-02.t [] +t/configure/146-auto_snprintf-03.t [] t/configure/147-auto_perldoc.t [] t/configure/148-auto_python.t [] t/configure/149-auto_m4.t [] Index: t/configure/146-auto_snprintf-01.t =================================================================== --- t/configure/146-auto_snprintf-01.t (revision 0) +++ t/configure/146-auto_snprintf-01.t (revision 0) @@ -0,0 +1,75 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 146-auto_snprintf-01.t + +use strict; +use warnings; +use Test::More qw(no_plan); # tests => 2; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::snprintf'); +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::snprintf}; + +$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("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +146-auto_snprintf-01.t - test config::auto::snprintf + +=head1 SYNOPSIS + + % prove t/configure/146-auto_snprintf-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::snprintf. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::snprintf, 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/146-auto_snprintf-01.t ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Index: t/configure/146-auto_snprintf.t =================================================================== --- t/configure/146-auto_snprintf.t (revision 22653) +++ t/configure/146-auto_snprintf.t (working copy) @@ -1,53 +0,0 @@ -#! perl -# Copyright (C) 2007, The Perl Foundation. -# $Id$ -# 146-auto_snprintf.t - -use strict; -use warnings; -use Test::More tests => 2; -use Carp; -use lib qw( lib ); -use_ok('config::auto::snprintf'); - -=for hints_for_testing The documentation for this package is skimpy; -please try to improve it, e.g., by providing a short description of what -the 'autosnprintf' is. Try to test all branches and conditions; consult -a recent code coverage report for guidance. - -=cut - -pass("Completed all tests in $0"); - -################### DOCUMENTATION ################### - -=head1 NAME - -146-auto_snprintf.t - test config::auto::snprintf - -=head1 SYNOPSIS - - % prove t/configure/146-auto_snprintf.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::snprintf. - -=head1 AUTHOR - -James E Keenan - -=head1 SEE ALSO - -config::auto::snprintf, F<Configure.pl>. - -=cut - -# Local Variables: -# mode: cperl -# cperl-indent-level: 4 -# fill-column: 100 -# End: -# vim: expandtab shiftwidth=4: Index: t/configure/146-auto_snprintf-02.t =================================================================== --- t/configure/146-auto_snprintf-02.t (revision 0) +++ t/configure/146-auto_snprintf-02.t (revision 0) @@ -0,0 +1,88 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 146-auto_snprintf-02.t + +use strict; +use warnings; +use Test::More qw(no_plan); # tests => 2; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::snprintf'); +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::snprintf}; + +$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 $res; +$res = q{old snprintf}; +ok($step->_evaluate_snprintf($conf, $res), + "_evaluate_snprintf returned true value"); +ok($conf->data->get('HAS_OLD_SNPRINTF'), + "Got expected value"); + +$res = q{C99 snprintf}; +ok($step->_evaluate_snprintf($conf, $res), + "_evaluate_snprintf returned true value"); +ok($conf->data->get('HAS_C99_SNPRINTF'), + "Got expected value"); +ok($conf->data->get('HAS_SNPRINTF'), + "Got expected value"); + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +146-auto_snprintf-02.t - test config::auto::snprintf + +=head1 SYNOPSIS + + % prove t/configure/146-auto_snprintf-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::snprintf. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::snprintf, 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/146-auto_snprintf-02.t ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Index: t/configure/146-auto_snprintf-03.t =================================================================== --- t/configure/146-auto_snprintf-03.t (revision 0) +++ t/configure/146-auto_snprintf-03.t (revision 0) @@ -0,0 +1,87 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 146-auto_snprintf-03.t + +use strict; +use warnings; +use Test::More qw(no_plan); # tests => 2; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::snprintf'); +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::snprintf}; + +$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 $tie_out = tie *STDOUT, "Parrot::IO::Capture::Mini" + or croak "Unable to tie"; + my $res = q{snprintf}; + ok($step->_evaluate_snprintf($conf, $res), + "_evaluate_snprintf returned true value"); + my @more_lines = $tie_out->READLINE; + ok( @more_lines, "verbose output captured" ); + ok($conf->data->get('HAS_SNPRINTF'), + "Got expected value"); +} +untie *STDOUT; + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +146-auto_snprintf-03.t - test config::auto::snprintf + +=head1 SYNOPSIS + + % prove t/configure/146-auto_snprintf-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::snprintf. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::snprintf, 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/146-auto_snprintf-03.t ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Index: config/auto/snprintf.pm =================================================================== --- config/auto/snprintf.pm (revision 22653) +++ config/auto/snprintf.pm (working copy) @@ -33,11 +33,23 @@ sub runstep { my ( $self, $conf ) = @_; + my $res = _probe_for_snprintf(); + + $self->_evaluate_snprintf($conf, $res); + + return 1; +} + +sub _probe_for_snprintf { cc_gen('config/auto/snprintf/test.in'); cc_build(); my $res = cc_run() or die "Can't run the snprintf testing program: $!"; cc_clean(); + return $res; +} +sub _evaluate_snprintf { + my ($self, $conf, $res) = @_; if ( $res =~ /snprintf/ ) { $conf->data->set( HAS_SNPRINTF => 1 ); } @@ -48,7 +60,6 @@ $conf->data->set( HAS_OLD_SNPRINTF => 1 ); } print " ($res) " if $conf->options->get('verbose'); - return 1; }