# New Ticket Created by  James Keenan 
# Please include the string:  [perl #49031]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=49031 >


The patch attached refactors config/auto/warnings.pm, renames one  
test file and provides six additional test files.  The purpose of the  
refactoring is to enable this class's internals to be more testable  
and achieve higher coverage by our test suite than is currently the  
case.  Components of runstep() and try_warnings() are refactored into  
subroutines which are individually tested by the additional test files.

This refactoring does not address the issues raised in various RT  
tickets about the config step and the existing test.  It works around  
those issues, I hope.  But I would like to see what happens when this  
is tried on various systems, including Win32.  Please review.

As I've done in some other configuration step classes, I've  
transformed data in package global ('our') variables into elements in  
the configuration step's data structure.

Thank you very much.
kid51

Index: MANIFEST
===================================================================
--- MANIFEST    (revision 24160)
+++ MANIFEST    (working copy)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Thu Dec 20 20:12:03 2007 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Sun Dec 23 01:42:19 2007 UT
 #
 # See tools/dev/install_files.pl for documentation on the
 # format of this file.
@@ -3135,7 +3135,13 @@
 t/configure/113-auto_msvc-02.t                              []
 t/configure/113-auto_msvc-03.t                              []
 t/configure/114-auto_attributes-01.t                        []
-t/configure/115-auto_warnings.t                             []
+t/configure/115-auto_warnings-01.t                          []
+t/configure/115-auto_warnings-02.t                          []
+t/configure/115-auto_warnings-03.t                          []
+t/configure/115-auto_warnings-04.t                          []
+t/configure/115-auto_warnings-05.t                          []
+t/configure/115-auto_warnings-06.t                          []
+t/configure/115-auto_warnings-07.t                          []
 t/configure/116-init_optimize-01.t                          []
 t/configure/116-init_optimize-02.t                          []
 t/configure/116-init_optimize-03.t                          []
Index: t/configure/115-auto_warnings-02.t
===================================================================
--- t/configure/115-auto_warnings-02.t  (revision 0)
+++ t/configure/115-auto_warnings-02.t  (revision 0)
@@ -0,0 +1,86 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 115-auto_warnings-02.t
+
+use strict;
+use warnings;
+use Test::More tests => 22;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::init::hints');
+use_ok('config::inter::progs');
+use_ok('config::auto::warnings');
+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 );
+test_step_thru_runstep( $conf, q{init::hints}, $args );
+test_step_thru_runstep( $conf, q{inter::progs}, $args );
+
+my $pkg = q{auto::warnings};
+
+$conf->add_steps($pkg);
+$conf->options->set( %{$args} );
+
+my ( $task, $step_name, $step);
+$task        = $conf->steps->[-1];
+$step_name   = $task->step;
+
+$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 %potential_warnings_seen;
+$conf->options->set(cage => 1);
+auto::warnings::_add_cage_warnings($step, $conf);
+%potential_warnings_seen = map { $_, 1 } @{ $step->{potential_warnings} };
+ok($potential_warnings_seen{'-std=c89'}, "Cage warning added");
+
+pass("Keep Devel::Cover happy");
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+115-auto_warnings-02.t - test config::auto::warnings
+
+=head1 SYNOPSIS
+
+    % prove t/configure/115-auto_warnings-02.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test aspects of config::auto::warnings.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::warnings, 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/115-auto_warnings-02.t
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Index: t/configure/115-auto_warnings-06.t
===================================================================
--- t/configure/115-auto_warnings-06.t  (revision 0)
+++ t/configure/115-auto_warnings-06.t  (revision 0)
@@ -0,0 +1,98 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 115-auto_warnings-06.t
+
+use strict;
+use warnings;
+use Test::More tests => 23;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::init::hints');
+use_ok('config::inter::progs');
+use_ok('config::auto::warnings');
+use Parrot::Configure;
+use Parrot::Configure::Options qw( process_options );
+use Parrot::Configure::Test qw( test_step_thru_runstep);
+use IO::CaptureOutput qw | capture |;
+
+my $args = process_options(
+    {
+        argv => [ ],
+        mode => q{configure},
+    }
+);
+
+my $conf = Parrot::Configure->new;
+
+test_step_thru_runstep( $conf, q{init::defaults}, $args );
+test_step_thru_runstep( $conf, q{init::hints}, $args );
+test_step_thru_runstep( $conf, q{inter::progs}, $args );
+
+my $pkg = q{auto::warnings};
+
+$conf->add_steps($pkg);
+$conf->options->set( %{$args} );
+
+my ( $task, $step_name, $step);
+$task        = $conf->steps->[-1];
+$step_name   = $task->step;
+
+$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 $warning = q{-Wphony_warning};
+#    my $stdout;
+#    capture(
+#        sub { auto::warnings::_set_warning($conf, $warning, 1, 1); },
+#        \$stdout,
+#    );
+#    ok(! $conf->data->get($warning),
+#        "Got expected setting for warning");
+#    like($stdout, qr/exit code:\s+1/, "Got expected verbose output");
+#}
+my $output = q{some string};
+my $tryflags = q{some flag};
+my $rv = auto::warnings::_set_ccflags($conf, $output, $tryflags, undef);
+is($rv, 1, "_set_ccflags() returned 1 as expected");
+is($conf->data->get("ccflags"), $tryflags, "ccflags changed as expected");
+
+pass("Keep Devel::Cover happy");
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+115-auto_warnings-06.t - test config::auto::warnings
+
+=head1 SYNOPSIS
+
+    % prove t/configure/115-auto_warnings-06.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test aspects of config::auto::warnings.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::warnings, 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/115-auto_warnings-06.t
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Index: t/configure/115-auto_warnings-03.t
===================================================================
--- t/configure/115-auto_warnings-03.t  (revision 0)
+++ t/configure/115-auto_warnings-03.t  (revision 0)
@@ -0,0 +1,86 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 115-auto_warnings-03.t
+
+use strict;
+use warnings;
+use Test::More tests => 22;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::init::hints');
+use_ok('config::inter::progs');
+use_ok('config::auto::warnings');
+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 );
+test_step_thru_runstep( $conf, q{init::hints}, $args );
+test_step_thru_runstep( $conf, q{inter::progs}, $args );
+
+my $pkg = q{auto::warnings};
+
+$conf->add_steps($pkg);
+$conf->options->set( %{$args} );
+
+my ( $task, $step_name, $step);
+$task        = $conf->steps->[-1];
+$step_name   = $task->step;
+
+$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 %potential_warnings_seen;
+$conf->options->set(maintainer => 1);
+auto::warnings::_add_maintainer_warnings($step, $conf);
+%potential_warnings_seen = map { $_, 1 } @{ $step->{potential_warnings} };
+ok($potential_warnings_seen{'-Wlarger-than-4096'}, "Maintainer warning added");
+
+pass("Keep Devel::Cover happy");
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+115-auto_warnings-03.t - test config::auto::warnings
+
+=head1 SYNOPSIS
+
+    % prove t/configure/115-auto_warnings-03.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test aspects of config::auto::warnings.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::warnings, 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/115-auto_warnings-03.t
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Index: t/configure/115-auto_warnings-07.t
===================================================================
--- t/configure/115-auto_warnings-07.t  (revision 0)
+++ t/configure/115-auto_warnings-07.t  (revision 0)
@@ -0,0 +1,94 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 115-auto_warnings-07.t
+
+use strict;
+use warnings;
+use Test::More tests => 24;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::init::hints');
+use_ok('config::inter::progs');
+use_ok('config::auto::warnings');
+use Parrot::Configure;
+use Parrot::Configure::Options qw( process_options );
+use Parrot::Configure::Test qw( test_step_thru_runstep);
+use IO::CaptureOutput qw | capture |;
+
+my $args = process_options(
+    {
+        argv => [ ],
+        mode => q{configure},
+    }
+);
+
+my $conf = Parrot::Configure->new;
+
+test_step_thru_runstep( $conf, q{init::defaults}, $args );
+test_step_thru_runstep( $conf, q{init::hints}, $args );
+test_step_thru_runstep( $conf, q{inter::progs}, $args );
+
+my $pkg = q{auto::warnings};
+
+$conf->add_steps($pkg);
+$conf->options->set( %{$args} );
+
+my ( $task, $step_name, $step);
+$task        = $conf->steps->[-1];
+$step_name   = $task->step;
+
+$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 $output = q{some string};
+    my $tryflags = q{some flag};
+    my ($rv, $stdout);
+    capture(
+        sub { $rv = auto::warnings::_set_ccflags($conf, $output, $tryflags, 
1); },
+        \$stdout,
+    );
+    is($rv, 1, "_set_ccflags() returned 1 as expected");
+    is($conf->data->get("ccflags"), $tryflags, "ccflags changed as expected");
+    like($stdout, qr/ccflags:\s+$tryflags/, "Got expected verbose output");
+}
+
+pass("Keep Devel::Cover happy");
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+115-auto_warnings-07.t - test config::auto::warnings
+
+=head1 SYNOPSIS
+
+    % prove t/configure/115-auto_warnings-07.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test aspects of config::auto::warnings.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::warnings, 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/115-auto_warnings-07.t
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Index: t/configure/115-auto_warnings-04.t
===================================================================
--- t/configure/115-auto_warnings-04.t  (revision 0)
+++ t/configure/115-auto_warnings-04.t  (revision 0)
@@ -0,0 +1,85 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 115-auto_warnings-04.t
+
+use strict;
+use warnings;
+use Test::More tests => 22;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::init::hints');
+use_ok('config::inter::progs');
+use_ok('config::auto::warnings');
+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 );
+test_step_thru_runstep( $conf, q{init::hints}, $args );
+test_step_thru_runstep( $conf, q{inter::progs}, $args );
+
+my $pkg = q{auto::warnings};
+
+$conf->add_steps($pkg);
+$conf->options->set( %{$args} );
+
+my ( $task, $step_name, $step);
+$task        = $conf->steps->[-1];
+$step_name   = $task->step;
+
+$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 $warning = q{-Wphony_warning};
+auto::warnings::_set_warning($conf, $warning, 1, undef);
+ok(! $conf->data->get($warning),
+    "Got expected setting for warning");
+
+pass("Keep Devel::Cover happy");
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+115-auto_warnings-04.t - test config::auto::warnings
+
+=head1 SYNOPSIS
+
+    % prove t/configure/115-auto_warnings-04.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test aspects of config::auto::warnings.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::warnings, 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/115-auto_warnings-04.t
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Index: t/configure/115-auto_warnings.t
===================================================================
--- t/configure/115-auto_warnings.t     (revision 24160)
+++ t/configure/115-auto_warnings.t     (working copy)
@@ -1,75 +0,0 @@
-#! perl
-# Copyright (C) 2007, The Perl Foundation.
-# $Id$
-# 115-auto_warnings.t
-
-use strict;
-use warnings;
-use Test::More;
-use Cwd;
-use Carp;
-use lib qw( lib );
-
-if ( $^O eq 'MSWin32' ) {
-    plan( skip_all => 'Not yet tested on Win32');
-}
-else {
-    plan( tests => 4 );
-}
-
-use_ok('Parrot::Configure');
-use_ok('Parrot::Configure::Step');
-use_ok('config::auto::warnings');
-
-my $step = 'dummy';
-
-my $conf = Parrot::Configure->new;
-$conf->data->set('cc', 'cc'); # RT#47395 Cannot assume there is a compiler 'cc'
-$conf->data->set('ccflags', '-I/usr/include'); # RT#47395 Cannot assume this.
-
-my $cwd = cwd();
-my $warning;
-
-TODO: {
-    # http://rt.perl.org/rt3/Ticket/Display.html?id=47395
-    local $TODO = q<Not all compilers support -Wall>;
-    $warning = "-Wall"; # RT#47395 Cannot assume all compilers accept -Wall.
-    {
-        my $verbose = 0;
-        my $rv      = auto::warnings::try_warning($step, $conf, $warning);
-        is( $rv, 1, "Got expected exit code of 1" );
-    }
-}
-
-################### DOCUMENTATION ###################
-
-=head1 NAME
-
-115-auto_warnings.t - test config::auto::warnings
-
-=head1 SYNOPSIS
-
-    % prove t/configure/115-auto_warnings.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::warnings.
-
-=head1 AUTHOR
-
-Paul Cochrane <paultcochrane at gmail dot com>
-
-=head1 SEE ALSO
-
-config::auto::warnings, F<Configure.pl>.
-
-=cut
-
-# Local Variables:
-#   mode: cperl
-#   cperl-indent-level: 4
-#   fill-column: 100
-# End:
-# vim: expandtab shiftwidth=4:
Index: t/configure/115-auto_warnings-01.t
===================================================================
--- t/configure/115-auto_warnings-01.t  (revision 0)
+++ t/configure/115-auto_warnings-01.t  (revision 0)
@@ -0,0 +1,75 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 115-auto_warnings-01.t
+
+use strict;
+use warnings;
+use Test::More;
+use Cwd;
+use Carp;
+use lib qw( lib );
+
+if ( $^O eq 'MSWin32' ) {
+    plan( skip_all => 'Not yet tested on Win32');
+}
+else {
+    plan( tests => 4 );
+}
+
+use_ok('Parrot::Configure');
+use_ok('Parrot::Configure::Step');
+use_ok('config::auto::warnings');
+
+my $step = 'dummy';
+
+my $conf = Parrot::Configure->new;
+$conf->data->set('cc', 'cc'); # RT#47395 Cannot assume there is a compiler 'cc'
+$conf->data->set('ccflags', '-I/usr/include'); # RT#47395 Cannot assume this.
+
+my $cwd = cwd();
+my $warning;
+
+TODO: {
+    # http://rt.perl.org/rt3/Ticket/Display.html?id=47395
+    local $TODO = q<Not all compilers support -Wall>;
+    $warning = "-Wall"; # RT#47395 Cannot assume all compilers accept -Wall.
+    {
+        my $verbose = 0;
+        my $rv      = auto::warnings::try_warning($step, $conf, $warning);
+        is( $rv, 1, "Got expected exit code of 1" );
+    }
+}
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+115-auto_warnings-01.t - test config::auto::warnings
+
+=head1 SYNOPSIS
+
+    % prove t/configure/115-auto_warnings-01.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test aspects of config::auto::warnings.
+
+=head1 AUTHOR
+
+Paul Cochrane <paultcochrane at gmail dot com>
+
+=head1 SEE ALSO
+
+config::auto::warnings, 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/115-auto_warnings-01.t
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Index: t/configure/115-auto_warnings-05.t
===================================================================
--- t/configure/115-auto_warnings-05.t  (revision 0)
+++ t/configure/115-auto_warnings-05.t  (revision 0)
@@ -0,0 +1,93 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 115-auto_warnings-05.t
+
+use strict;
+use warnings;
+use Test::More tests => 23;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::init::hints');
+use_ok('config::inter::progs');
+use_ok('config::auto::warnings');
+use Parrot::Configure;
+use Parrot::Configure::Options qw( process_options );
+use Parrot::Configure::Test qw( test_step_thru_runstep);
+use IO::CaptureOutput qw | capture |;
+
+my $args = process_options(
+    {
+        argv => [ ],
+        mode => q{configure},
+    }
+);
+
+my $conf = Parrot::Configure->new;
+
+test_step_thru_runstep( $conf, q{init::defaults}, $args );
+test_step_thru_runstep( $conf, q{init::hints}, $args );
+test_step_thru_runstep( $conf, q{inter::progs}, $args );
+
+my $pkg = q{auto::warnings};
+
+$conf->add_steps($pkg);
+$conf->options->set( %{$args} );
+
+my ( $task, $step_name, $step);
+$task        = $conf->steps->[-1];
+$step_name   = $task->step;
+
+$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 $warning = q{-Wphony_warning};
+    my $stdout;
+    capture(
+        sub { auto::warnings::_set_warning($conf, $warning, 1, 1); },
+        \$stdout,
+    );
+    ok(! $conf->data->get($warning),
+        "Got expected setting for warning");
+    like($stdout, qr/exit code:\s+1/, "Got expected verbose output");
+}
+
+pass("Keep Devel::Cover happy");
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+115-auto_warnings-05.t - test config::auto::warnings
+
+=head1 SYNOPSIS
+
+    % prove t/configure/115-auto_warnings-05.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file test aspects of config::auto::warnings.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::warnings, 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/115-auto_warnings-05.t
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Index: config/auto/warnings.pm
===================================================================
--- config/auto/warnings.pm     (revision 24160)
+++ config/auto/warnings.pm     (working copy)
@@ -34,118 +34,127 @@
     $data{description} = q{Detecting supported compiler warnings (-Wxxx)};
     $data{args}        = [ qw( cc verbose define  ) ];
     $data{result}      = q{};
+
+    # potential addition? -fvisibility=hidden
+    my @potential_warnings = qw(
+        -falign-functions=16
+        -mno-accumulate-outgoing-args
+        -W
+        -Wall
+        -Waggregate-return
+        -Wbad-function-cast
+        -Wc++-compat
+        -Wcast-align
+        -Wcast-qual
+        -Wchar-subscripts
+        -Wcomment
+        -Wdeclaration-after-statement
+        -Wdisabled-optimization
+        -Wextra
+        -Wformat-nonliteral
+        -Wformat-security
+        -Wformat-y2k
+        -Wimplicit
+        -Wimplicit-function-declaration
+        -Wimplicit-int
+        -Wimport
+        -Winit-self
+        -Winline
+        -Winvalid-pch
+        -Wlogical-op
+        -Wmain
+        -Wmissing-braces
+        -Wmissing-declarations
+        -Wmissing-field-initializers
+        -Wmissing-include-dirs
+        -Wmissing-prototypes
+        -Wnested-externs
+        -Wno-accumulate-outgoing-args
+        -Wno-endif-labels
+        -Wno-shadow
+        -Wno-unused
+        -Wnonnull
+        -Wold-style-definition
+        -Wpacked
+        -Wparentheses
+        -Wpointer-arith
+        -Wreturn-type
+        -Wsequence-point
+        -Wsign-compare
+        -Wstrict-aliasing
+        -Wstrict-aliasing=2
+        -Wstrict-prototypes
+        -Wswitch
+        -Wswitch-default
+        -Wtrigraphs
+        -Wundef
+        -Wunknown-pragmas
+        -Wvariadic-macros
+        -Wwrite-strings
+        -Wnot-a-real-warning
+    );
+    
+    my @cage_warnings = qw(
+        -std=c89
+        -Wconversion
+        -Werror-implicit-function-declaration
+        -Wformat=2
+        -Wlarger-than-4096
+        -Wlong-long
+        -Wmissing-format-attribute
+        -Wmissing-noreturn
+        -Wno-deprecated-declarations
+        -Wno-div-by-zero
+        -Wno-format-extra-args
+        -Wno-import
+        -Wno-multichar
+        -Wno-pointer-sign
+        -Wpadded
+        -Wredundant-decls
+        -Wswitch-enum
+        -Wsystem-headers
+        -Wunreachable-code
+        -Wunused-function
+        -Wunused-label
+        -Wunused-parameter
+        -Wunused-value
+        -Wunused-variable
+    );
+    
+    $data{potential_warnings} = [EMAIL PROTECTED];
+    $data{cage_warnings} = [EMAIL PROTECTED];
     return \%data;
 }
 
-# potential addition? -fvisibility=hidden
-
-our @potential_warnings = qw(
-    -falign-functions=16
-    -mno-accumulate-outgoing-args
-    -W
-    -Wall
-    -Waggregate-return
-    -Wbad-function-cast
-    -Wc++-compat
-    -Wcast-align
-    -Wcast-qual
-    -Wchar-subscripts
-    -Wcomment
-    -Wdeclaration-after-statement
-    -Wdisabled-optimization
-    -Wextra
-    -Wformat-nonliteral
-    -Wformat-security
-    -Wformat-y2k
-    -Wimplicit
-    -Wimplicit-function-declaration
-    -Wimplicit-int
-    -Wimport
-    -Winit-self
-    -Winline
-    -Winvalid-pch
-    -Wlogical-op
-    -Wmain
-    -Wmissing-braces
-    -Wmissing-declarations
-    -Wmissing-field-initializers
-    -Wmissing-include-dirs
-    -Wmissing-prototypes
-    -Wnested-externs
-    -Wno-accumulate-outgoing-args
-    -Wno-endif-labels
-    -Wno-shadow
-    -Wno-unused
-    -Wnonnull
-    -Wold-style-definition
-    -Wpacked
-    -Wparentheses
-    -Wpointer-arith
-    -Wreturn-type
-    -Wsequence-point
-    -Wsign-compare
-    -Wstrict-aliasing
-    -Wstrict-aliasing=2
-    -Wstrict-prototypes
-    -Wswitch
-    -Wswitch-default
-    -Wtrigraphs
-    -Wundef
-    -Wunknown-pragmas
-    -Wvariadic-macros
-    -Wwrite-strings
-    -Wnot-a-real-warning
-);
-
-our @cage_warnings = qw(
-    -std=c89
-    -Wconversion
-    -Werror-implicit-function-declaration
-    -Wformat=2
-    -Wlarger-than-4096
-    -Wlong-long
-    -Wmissing-format-attribute
-    -Wmissing-noreturn
-    -Wno-deprecated-declarations
-    -Wno-div-by-zero
-    -Wno-format-extra-args
-    -Wno-import
-    -Wno-multichar
-    -Wno-pointer-sign
-    -Wpadded
-    -Wredundant-decls
-    -Wswitch-enum
-    -Wsystem-headers
-    -Wunreachable-code
-    -Wunused-function
-    -Wunused-label
-    -Wunused-parameter
-    -Wunused-value
-    -Wunused-variable
-    );
-
-our $verbose;
-
 sub runstep {
     my ( $self, $conf ) = @_;
 
-    $verbose = $conf->options->get('verbose');
+    my $verbose = $conf->options->get('verbose');
     print "\n" if $verbose;
 
     # add on some extra warnings if requested
-    push @potential_warnings, @cage_warnings
-        if $conf->options->get('cage');
+    _add_cage_warnings($self, $conf);
+    _add_maintainer_warnings($self, $conf);
 
-    push @potential_warnings, '-Wlarger-than-4096'
-        if $conf->options->get('maintainer');
-
     # now try out our warnings
-    for my $maybe_warning (@potential_warnings) {
-        $self->try_warning( $conf, $maybe_warning );
+    for my $maybe_warning (@{ $self->{potential_warnings} }) {
+        $self->try_warning( $conf, $maybe_warning, $verbose );
     }
     return 1;
 }
 
+sub _add_cage_warnings {
+    my ($self, $conf) = @_;
+    push @{ $self->{potential_warnings} }, @{ $self->{cage_warnings} }
+        if $conf->options->get('cage');
+}
+
+sub _add_maintainer_warnings {
+    my ($self, $conf) = @_;
+    push @{ $self->{potential_warnings} }, '-Wlarger-than-4096'
+        if $conf->options->get('maintainer');
+}
+
 =item C<try_warning>
 
 Try a given warning to see if it is supported by the compiler.  The compiler
@@ -159,7 +168,7 @@
 =cut
 
 sub try_warning {
-    my ( $self, $conf, $warning ) = @_;
+    my ( $self, $conf, $warning, $verbose ) = @_;
 
     my $output_file = 'test.cco';
 
@@ -175,21 +184,30 @@
     $verbose and print "  ", $command_line, "\n";
 
     # Don't use cc_build, because failure is expected.
-    my $exit_code =
-        Parrot::Configure::Step::_run_command( $command_line, $output_file, 
$output_file );
-    $verbose and print "  exit code: $exit_code\n";
+    my $exit_code = Parrot::Configure::Step::_run_command(
+        $command_line, $output_file, $output_file
+    );
+    _set_warning($conf, $warning, $exit_code, $verbose);
 
-    $conf->data->set( $warning => !$exit_code | 0 );
-
     return if $exit_code;
 
     my $output = Parrot::BuildUtil::slurp_file($output_file);
+    return _set_ccflags($conf, $output, $tryflags, $verbose);
+}
+
+sub _set_warning {
+    my ($conf, $warning, $exit_code, $verbose) = @_;
+    $verbose and print "  exit code: $exit_code\n";
+    $conf->data->set( $warning => !$exit_code || 0 );
+}
+
+sub _set_ccflags {
+    my ($conf, $output, $tryflags, $verbose) = @_;
     $verbose and print "  output: $output\n";
 
     if ( $output !~ /error|warning|not supported/i ) {
         $conf->data->set( ccflags => $tryflags );
-        my $ccflags = $conf->data->get("ccflags");
-        $verbose and print "  ccflags: $ccflags\n";
+        $verbose and print "  ccflags: ", $conf->data->get("ccflags"), "\n";
         return 1;
     }
     else {

Reply via email to