The patch refactors configuration step class auto::isreg to increase
testability in a manner similar to other recent patches. The two C
probes are refactored into individual internal subroutines and an
internal method handles the rest of the code inside runstep(). Three
additional test files are contributed: t/configure/131-auto_isreg-01.t,
-02.t and -03.t. All statements are covered by tests, though three
branches are, for practical purposes, uncoverable. No change in
functionality.
Will apply in 2-3 days if no objection.
kid51
Index: MANIFEST
===================================================================
--- MANIFEST (revision 22649)
+++ 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 Thu Nov 1 01:49:58 2007 UT
#
# See tools/dev/install_files.pl for documentation on the
# format of this file.
@@ -3067,7 +3067,9 @@
t/configure/128-auto_va_ptr.t []
t/configure/129-auto_pack.t []
t/configure/130-auto_format.t []
-t/configure/131-auto_isreg.t []
+t/configure/131-auto_isreg-01.t []
+t/configure/131-auto_isreg-02.t []
+t/configure/131-auto_isreg-03.t []
t/configure/132-auto_jit-01.t []
t/configure/133-gen_cpu.t []
t/configure/134-auto_funcptr.t []
Index: t/configure/131-auto_isreg.t
===================================================================
--- t/configure/131-auto_isreg.t (revision 22649)
+++ t/configure/131-auto_isreg.t (working copy)
@@ -1,53 +0,0 @@
-#! perl
-# Copyright (C) 2007, The Perl Foundation.
-# $Id$
-# 131-auto_isreg.t
-
-use strict;
-use warnings;
-use Test::More tests => 2;
-use Carp;
-use lib qw( lib );
-use_ok('config::auto::isreg');
-
-=for hints_for_testing The documentation of the package being tested is
-insufficient; please try to improve it. 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
-
-131-auto_isreg.t - test config::auto::isreg
-
-=head1 SYNOPSIS
-
- % prove t/configure/131-auto_isreg.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::isreg.
-
-=head1 AUTHOR
-
-James E Keenan
-
-=head1 SEE ALSO
-
-config::auto::isreg, F<Configure.pl>.
-
-=cut
-
-# Local Variables:
-# mode: cperl
-# cperl-indent-level: 4
-# fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:
Index: t/configure/131-auto_isreg-02.t
===================================================================
--- t/configure/131-auto_isreg-02.t (revision 0)
+++ t/configure/131-auto_isreg-02.t (revision 0)
@@ -0,0 +1,87 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 131-auto_isreg-02.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::isreg');
+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::isreg};
+
+$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 $anyerror;
+ ok($step->_evaluate_isreg($conf, $anyerror),
+ "_evaluate_isreg returned true value");
+ my @more_lines = $tie_out->READLINE;
+ ok( @more_lines, "verbose output captured" );
+ is($conf->data->get('isreg'), 1, "'isreg' set to true value as expected");
+ is($step->result, 'yes', "Got expected result");
+}
+untie *STDOUT;
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+131-auto_isreg-02.t - test config::auto::isreg
+
+=head1 SYNOPSIS
+
+ % prove t/configure/131-auto_isreg-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::isreg.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::isreg, 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/131-auto_isreg-02.t
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Index: t/configure/131-auto_isreg-03.t
===================================================================
--- t/configure/131-auto_isreg-03.t (revision 0)
+++ t/configure/131-auto_isreg-03.t (revision 0)
@@ -0,0 +1,87 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 131-auto_isreg-03.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::isreg');
+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::isreg};
+
+$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 $anyerror = 1;
+ ok($step->_evaluate_isreg($conf, $anyerror),
+ "_evaluate_isreg returned true value");
+ my @more_lines = $tie_out->READLINE;
+ ok( @more_lines, "verbose output captured" );
+ is($conf->data->get('isreg'), 0, "'isreg' set to false value as expected");
+ is($step->result, 'no', "Got expected result");
+}
+untie *STDOUT;
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+131-auto_isreg-03.t - test config::auto::isreg
+
+=head1 SYNOPSIS
+
+ % prove t/configure/131-auto_isreg-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::isreg.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::isreg, 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/131-auto_isreg-03.t
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Index: t/configure/131-auto_isreg-01.t
===================================================================
--- t/configure/131-auto_isreg-01.t (revision 0)
+++ t/configure/131-auto_isreg-01.t (revision 0)
@@ -0,0 +1,75 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 131-auto_isreg-01.t
+
+use strict;
+use warnings;
+use Test::More tests => 11;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::auto::isreg');
+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::isreg};
+
+$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
+
+131-auto_isreg-01.t - test config::auto::isreg
+
+=head1 SYNOPSIS
+
+ % prove t/configure/131-auto_isreg-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::isreg.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::isreg, 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/131-auto_isreg-01.t
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Index: config/auto/isreg.pm
===================================================================
--- config/auto/isreg.pm (revision 22649)
+++ config/auto/isreg.pm (working copy)
@@ -33,19 +33,37 @@
sub runstep {
my ( $self, $conf ) = @_;
- my $test = 0;
+ my $errormsg = _first_probe_for_isreg();
- cc_gen('config/auto/isreg/test_c.in');
- eval { cc_build(); };
- unless ( $@ || cc_run() !~ /ok/ ) {
- $test = 1;
+ if (! $errormsg) {
+ $errormsg = _second_probe_for_isreg();
}
cc_clean();
+ $self->_evaluate_isreg($conf, $errormsg);
+ return 1;
+}
+sub _first_probe_for_isreg {
+ my $errormsg;
+ cc_gen('config/auto/isreg/test_c.in');
+ eval { cc_build(); };
+ $errormsg = 1 if $@;
+ return $errormsg;
+}
+
+sub _second_probe_for_isreg {
+ my $ccrunfailure;
+ $ccrunfailure++ if ( cc_run() !~ /ok/ );
+ return $ccrunfailure;
+}
+
+sub _evaluate_isreg {
+ my ($self, $conf, $anyerror) = @_;
+ my $test;
+ $test = (! defined $anyerror) ? 1 : 0;
$conf->data->set( isreg => $test );
print( $test ? " (Yep) " : " (no) " ) if $conf->options->get('verbose');
$self->set_result( $test ? 'yes' : 'no' );
-
return 1;
}