Author: jkeenan
Date: Tue Oct 30 19:09:28 2007
New Revision: 22629

Added:
   trunk/t/configure/112-auto_backtrace-01.t
      - copied, changed from r22532, /trunk/t/configure/112-auto_backtrace.t
   trunk/t/configure/112-auto_backtrace-02.t   (contents, props changed)
   trunk/t/configure/113-auto_msvc-01.t   (contents, props changed)
   trunk/t/configure/113-auto_msvc-02.t   (contents, props changed)
   trunk/t/configure/113-auto_msvc-03.t   (contents, props changed)
Removed:
   trunk/t/configure/112-auto_backtrace.t
   trunk/t/configure/113-auto_msvc.t
Modified:
   trunk/MANIFEST
   trunk/config/auto/backtrace.pm
   trunk/config/auto/msvc.pm
   trunk/t/configure/036-config_steps.t
   trunk/t/configure/111-auto_gcc.t
   trunk/t/configure/139-auto_signal-01.t

Log:
config/auto/msvc.pm:  Refactored configuration step class and associated
test files as submitted in
http://rt.perl.org/rt3/Ticket/Display.html?id=43314.  Also,
config/auto/backtrace.pm:  Very similar refactorings and associatged
test modules.  Some minor changes in some other t/configure/*.t test
files, mostly to facilitate coverage analysis.  Updated MANIFEST.


Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST      (original)
+++ trunk/MANIFEST      Tue Oct 30 19:09:28 2007
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Tue Oct 30 12:09:48 2007 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Wed Oct 31 01:48:56 2007 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -3014,8 +3014,11 @@
 t/configure/110-inter_yacc-04.t                             []
 t/configure/110-inter_yacc-05.t                             []
 t/configure/111-auto_gcc.t                                  []
-t/configure/112-auto_backtrace.t                            []
-t/configure/113-auto_msvc.t                                 []
+t/configure/112-auto_backtrace-01.t                         []
+t/configure/112-auto_backtrace-02.t                         []
+t/configure/113-auto_msvc-01.t                              []
+t/configure/113-auto_msvc-02.t                              []
+t/configure/113-auto_msvc-03.t                              []
 t/configure/114-auto_attributes.t                           []
 t/configure/115-auto_warnings.t                             []
 t/configure/116-init_optimize-01.t                          []

Modified: trunk/config/auto/backtrace.pm
==============================================================================
--- trunk/config/auto/backtrace.pm      (original)
+++ trunk/config/auto/backtrace.pm      Tue Oct 30 19:09:28 2007
@@ -33,8 +33,14 @@
 sub runstep {
     my ( $self, $conf ) = @_;
 
-    my $verbose = $conf->options->get('verbose');
+    my $anyerror = _probe_for_backtrace();
 
+    $self->_evaluate_backtrace($conf, $anyerror);
+
+    return 1;
+}
+
+sub _probe_for_backtrace {
     cc_gen("config/auto/backtrace/test_c.in");
 
     # If the program builds (e.g. the linker found backtrace* in libc)
@@ -43,15 +49,19 @@
     # build failure is because these symbols are missing.
 
     eval { cc_build(); };
-    if ( $@ ) {
+    my $anyerror = $@ if $@;
+    cc_clean();
+    return $anyerror;
+}
+
+sub _evaluate_backtrace {
+    my ($self, $conf, $anyerror) = @_;
+    if ( $anyerror ) {
         $self->set_result("no");
     } else {
         $conf->data->set( glibc_backtrace => 1 );
         $self->set_result("yes");
     }
-    cc_clean();
-
-    return 1;
 }
 
 1;

Modified: trunk/config/auto/msvc.pm
==============================================================================
--- trunk/config/auto/msvc.pm   (original)
+++ trunk/config/auto/msvc.pm   Tue Oct 30 19:09:28 2007
@@ -33,13 +33,24 @@
 sub runstep {
     my ( $self, $conf ) = ( shift, shift );
 
-    my $verbose = $conf->options->get('verbose');
+    my $msvcref = _probe_for_msvc();
+
+    $self->_evaluate_msvc($conf, $msvcref);
+
+    return 1;
+}
 
+sub _probe_for_msvc {
     cc_gen("config/auto/msvc/test_c.in");
     cc_build();
     my %msvc = eval cc_run() or die "Can't run the test program: $!";
     cc_clean();
+    return \%msvc;
+}
 
+sub _evaluate_msvc {
+    my ($self, $conf, $msvcref) = @_;
+    my $verbose = $conf->options->get('verbose');
     # Set msvcversion to undef.  This will also trigger any hints-file
     # callbacks that depend on knowing whether or not we're using Visual C++.
 
@@ -47,14 +58,14 @@
     # which should have been caught by the 'die' above.
     # Therefore, test if it's defined to see if MSVC's installed.
     # return 'no' if it's not.
-    unless ( defined $msvc{_MSC_VER} ) {
+    unless ( defined $msvcref->{_MSC_VER} ) {
         $self->set_result('no');
         $conf->data->set( msvcversion => undef );
         return 1;
     }
 
-    my $major = int( $msvc{_MSC_VER} / 100 );
-    my $minor = $msvc{_MSC_VER} % 100;
+    my $major = int( $msvcref->{_MSC_VER} / 100 );
+    my $minor = $msvcref->{_MSC_VER} % 100;
     unless ( defined $major && defined $minor ) {
         print " (no) " if $verbose;
         $self->set_result('no');
@@ -79,7 +90,6 @@
         # for details.
         $conf->data->add( " ", "ccflags", "-D_CRT_SECURE_NO_DEPRECATE" );
     }
-
     return 1;
 }
 

Modified: trunk/t/configure/036-config_steps.t
==============================================================================
--- trunk/t/configure/036-config_steps.t        (original)
+++ trunk/t/configure/036-config_steps.t        Tue Oct 30 19:09:28 2007
@@ -32,7 +32,7 @@
     @steps = grep { $_ !~ /win32/i } @steps;
 }
 
-my $testcount = @steps + 1;
+my $testcount = @steps + 2;
 
 # my $testcount = @steps;
 
@@ -41,6 +41,7 @@
     require_ok($step);
 }
 
+pass("Keep Devel::Cover happy");
 pass("Completed all tests in $0");
 
 # Local Variables:

Modified: trunk/t/configure/111-auto_gcc.t
==============================================================================
--- trunk/t/configure/111-auto_gcc.t    (original)
+++ trunk/t/configure/111-auto_gcc.t    Tue Oct 30 19:09:28 2007
@@ -5,7 +5,7 @@
 
 use strict;
 use warnings;
-use Test::More tests => 10;
+use Test::More tests => 11;
 use Carp;
 use lib qw( lib t/configure/testlib );
 use_ok('config::init::defaults');
@@ -37,6 +37,7 @@
 isa_ok($step, $step_name);
 ok($step->description(), "$step_name has description");
 
+pass("Keep Devel::Cover happy");
 pass("Completed all tests in $0");
 
 ################### DOCUMENTATION ###################

Copied: trunk/t/configure/112-auto_backtrace-01.t (from r22532, 
/trunk/t/configure/112-auto_backtrace.t)
==============================================================================
--- /trunk/t/configure/112-auto_backtrace.t     (original)
+++ trunk/t/configure/112-auto_backtrace-01.t   Tue Oct 30 19:09:28 2007
@@ -1,11 +1,11 @@
 #! perl
 # Copyright (C) 2007, The Perl Foundation.
 # $Id$
-# 112-auto_backtrace.t
+# 112-auto_backtrace-01.t
 
 use strict;
 use warnings;
-use Test::More tests => 10;
+use Test::More tests => 11;
 use Carp;
 use lib qw( lib t/configure/testlib );
 use_ok('config::init::defaults');
@@ -37,23 +37,26 @@
 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
 
-112-auto_backtrace.t - test config::auto::backtrace
+112-auto_backtrace-01.t - test config::auto::backtrace
 
 =head1 SYNOPSIS
 
-    % prove t/configure/112-auto_backtrace.t
+    % prove t/configure/112-auto_backtrace-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::backtrace.
+The tests in this file test subroutines exported by
+config::auto::backtrace.
 
 =head1 AUTHOR
 

Added: trunk/t/configure/112-auto_backtrace-02.t
==============================================================================
--- (empty file)
+++ trunk/t/configure/112-auto_backtrace-02.t   Tue Oct 30 19:09:28 2007
@@ -0,0 +1,80 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 112-auto_backtrace-02.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::backtrace');
+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::backtrace};
+
+$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 $error = q{mock_error};
+ok($step->_evaluate_backtrace($conf, $error),
+    "_evaluate_backtrace returned true value");
+
+is($step->result, 'no', "Got expected result");
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+112-auto_backtrace-02.t - test config::auto::backtrace
+
+=head1 SYNOPSIS
+
+    % prove t/configure/112-auto_backtrace-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::backtrace.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::backtrace, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Added: trunk/t/configure/113-auto_msvc-01.t
==============================================================================
--- (empty file)
+++ trunk/t/configure/113-auto_msvc-01.t        Tue Oct 30 19:09:28 2007
@@ -0,0 +1,82 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 113-auto_msvc-01.t
+
+use strict;
+use warnings;
+use Test::More qw(no_plan); # tests => 11;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::auto::msvc');
+use Parrot::Configure;
+use Parrot::Configure::Options qw( process_options );
+use Parrot::Configure::Test qw( test_step_thru_runstep);
+
+=for hints_for_testing Testing config::auto::msvc::runstep() may be
+meaningless if you are not on Windows.  Consider writing a SKIP block.  Check
+latest reports of Parrot configuration tools testing coverage to see where
+your time available for writing tests is spent.
+
+=cut
+
+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::msvc};
+
+$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
+
+113-auto_msvc-01.t - test config::auto::msvc
+
+=head1 SYNOPSIS
+
+    % prove t/configure/113-auto_msvc-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::msvc.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::msvc, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Added: trunk/t/configure/113-auto_msvc-02.t
==============================================================================
--- (empty file)
+++ trunk/t/configure/113-auto_msvc-02.t        Tue Oct 30 19:09:28 2007
@@ -0,0 +1,82 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 113-auto_msvc-02.t
+
+use strict;
+use warnings;
+use Test::More tests => 13;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::auto::msvc');
+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::msvc};
+
+$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 $msvcref = { _MSC_VER => 1399 };
+ok($step->_evaluate_msvc($conf, $msvcref),
+    "_evaluate_msvc returned true value");
+
+is($step->result, 'yes', "Got expected result");
+
+is($conf->data->get('msvcversion'), '13.99',
+    "Got expected msvc version string");
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+113-auto_msvc-02.t - test config::auto::msvc
+
+=head1 SYNOPSIS
+
+    % prove t/configure/113-auto_msvc-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::msvc.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::msvc, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Added: trunk/t/configure/113-auto_msvc-03.t
==============================================================================
--- (empty file)
+++ trunk/t/configure/113-auto_msvc-03.t        Tue Oct 30 19:09:28 2007
@@ -0,0 +1,95 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 113-auto_msvc-03.t
+
+use strict;
+use warnings;
+use Test::More qw(no_plan); # tests => 11;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::auto::msvc');
+use Parrot::Configure;
+use Parrot::Configure::Options qw( process_options );
+use Parrot::Configure::Test qw( test_step_thru_runstep);
+
+=for hints_for_testing Testing config::auto::msvc::runstep() may be
+meaningless if you are not on Windows.  Consider writing a SKIP block.  Check
+latest reports of Parrot configuration tools testing coverage to see where
+your time available for writing tests is spent.
+
+=cut
+
+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::msvc};
+
+$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 $msvcref = { _MSC_VER => 1400 };
+ok($step->_evaluate_msvc($conf, $msvcref),
+    "_evaluate_msvc returned true value");
+
+is($step->result, 'yes', "Got expected result");
+
+is($conf->data->get('msvcversion'), '14.0',
+    "Got expected msvc version string");
+
+like(
+    $conf->data->get('ccflags'),
+    qr/\-D_CRT_SECURE_NO_DEPRECATE/,
+    "ccflags appropriately adjusted given MSVC version"
+);
+
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+113-auto_msvc-03.t - test config::auto::msvc
+
+=head1 SYNOPSIS
+
+    % prove t/configure/113-auto_msvc-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::msvc.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::msvc, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+#   mode: cperl
+#   cperl-indent-level: 4
+#   fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:

Modified: trunk/t/configure/139-auto_signal-01.t
==============================================================================
--- trunk/t/configure/139-auto_signal-01.t      (original)
+++ trunk/t/configure/139-auto_signal-01.t      Tue Oct 30 19:09:28 2007
@@ -5,7 +5,7 @@
 
 use strict;
 use warnings;
-use Test::More tests => 12;
+use Test::More tests => 13;
 use Carp;
 use lib qw( lib t/configure/testlib );
 use_ok('config::init::defaults');
@@ -44,6 +44,7 @@
 ok( $ret, "$step_name runstep() returned true value" );
 is($step->result(), q{skipped}, "Expected result was set");
 
+pass("Keep Devel::Cover happy");
 pass("Completed all tests in $0");
 
 ################### DOCUMENTATION ###################

Reply via email to