Patch attached refactors configuration step auto::socklen_t to maximize
testability.  Patch also includes two test files which replace
placeholder file.  Will commit to trunk in 2-3 days if there is no
objection.
Index: MANIFEST
===================================================================
--- MANIFEST    (revision 22711)
+++ MANIFEST    (working copy)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Sun Nov  4 15:38:46 2007 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Mon Nov  5 03:18:19 2007 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -3082,7 +3082,8 @@
 t/configure/137-auto_gc.t                                   []
 t/configure/138-auto_memalign-01.t                          []
 t/configure/139-auto_signal-01.t                            []
-t/configure/140-auto_socklen_t.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/142-auto_aio.t                                  []
 t/configure/143-auto_gmp.t                                  []
Index: t/configure/140-auto_socklen_t-01.t
===================================================================
--- t/configure/140-auto_socklen_t-01.t (revision 0)
+++ t/configure/140-auto_socklen_t-01.t (revision 0)
@@ -0,0 +1,80 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 140-auto_socklen_t-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::socklen_t');
+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::socklen_t};
+
+$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 $ret = $step->runstep($conf);
+ok( $ret, "$step_name runstep() returned true value" );
+ok(defined($step->result()), "A result has been defiined");
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+140-auto_socklen_t-01.t - test config::auto::socklen_t
+
+=head1 SYNOPSIS
+
+    % prove t/configure/140-auto_socklen_t-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::socklen_t.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::socklen_t, 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/140-auto_socklen_t-01.t
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Index: t/configure/140-auto_socklen_t.t
===================================================================
--- t/configure/140-auto_socklen_t.t    (revision 22711)
+++ t/configure/140-auto_socklen_t.t    (working copy)
@@ -1,54 +0,0 @@
-#! perl
-# Copyright (C) 2007, The Perl Foundation.
-# $Id$
-# 140-auto_socklen_t.t
-
-use strict;
-use warnings;
-use Test::More tests =>  2;
-use Carp;
-use lib qw( lib );
-use_ok('config::auto::socklen_t');
-
-=for hints_for_testing The documentation for this package is skimpy;
-please try to improve it, e.g., by explaining what a socklent_t is.  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
-
-140-auto_socklen_t.t - test config::auto::socklen_t
-
-=head1 SYNOPSIS
-
-    % prove t/configure/140-auto_socklen_t.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::socklen_t.
-
-=head1 AUTHOR
-
-James E Keenan
-
-=head1 SEE ALSO
-
-config::auto::socklen_t, F<Configure.pl>.
-
-=cut
-
-# Local Variables:
-#   mode: cperl
-#   cperl-indent-level: 4
-#   fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:
Index: t/configure/140-auto_socklen_t-02.t
===================================================================
--- t/configure/140-auto_socklen_t-02.t (revision 0)
+++ t/configure/140-auto_socklen_t-02.t (revision 0)
@@ -0,0 +1,96 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 140-auto_socklen_t-02.t
+
+use strict;
+use warnings;
+use Test::More qw(no_plan); # tests => 12;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::auto::socklen_t');
+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::socklen_t};
+
+$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 $ret = $step->runstep($conf);
+#ok( $ret, "$step_name runstep() returned true value" );
+#ok(defined($step->result()), "A result has been defiined");
+my $d_socklen_t;
+
+$d_socklen_t = q{alpha};
+ok($step->_evaluate_socklen_t($conf, $d_socklen_t),
+    "_evaluate_socklen_t() completed satisfactorily");
+is($step->result(), q{yes}, "Got expected result");
+is($conf->data->get('has_socklen_t'), 1,
+    "has_socklen_t set as expected");
+
+$d_socklen_t = undef;
+ok($step->_evaluate_socklen_t($conf, $d_socklen_t),
+    "_evaluate_socklen_t() completed satisfactorily");
+is($step->result(), q{no}, "Got expected result");
+is($conf->data->get('has_socklen_t'), 0,
+    "has_socklen_t set as expected");
+
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+140-auto_socklen_t-02.t - test config::auto::socklen_t
+
+=head1 SYNOPSIS
+
+    % prove t/configure/140-auto_socklen_t-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::socklen_t.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::socklen_t, 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/140-auto_socklen_t-02.t
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Index: config/auto/socklen_t.pm
===================================================================
--- config/auto/socklen_t.pm    (revision 22711)
+++ config/auto/socklen_t.pm    (working copy)
@@ -35,15 +35,25 @@
 sub runstep {
     my ( $self, $conf ) = @_;
 
-    my $d_socklen_t = $conf->data->get('has_socklen_t');
-    $d_socklen_t = $Config{d_socklen_t} unless defined $d_socklen_t;
-    my $has_socklen_t = ( $d_socklen_t && $d_socklen_t ne 'undef' ) ? 1 : 0;
-    $self->set_result( $has_socklen_t ? 'yes' : 'no' );
-    $conf->data->set( has_socklen_t => $has_socklen_t, );
+    my $d_socklen_t = _probe_for_socklen_t($conf);
 
+    $self->_evaluate_socklen_t($conf, $d_socklen_t);
+
     return 1;
 }
 
+sub _probe_for_socklen_t {
+    my $conf = shift;
+    return $conf->data->get('has_socklen_t') || $Config{d_socklen_t};
+}
+
+sub _evaluate_socklen_t {
+    my ($self, $conf, $d_socklen_t) = @_;
+    my $has_socklen_t = $d_socklen_t ? 1 : 0;
+    $self->set_result( $has_socklen_t ? 'yes' : 'no' );
+    $conf->data->set( has_socklen_t => $has_socklen_t );
+}
+
 1;
 
 # Local Variables:

Reply via email to