[svn:parrot] r42588 - in trunk: . config/init/hints t/steps/init/hints

jkeenan at svn.parrot.org jkeenan at svn.parrot.org
Fri Nov 20 00:51:17 UTC 2009


Author: jkeenan
Date: Fri Nov 20 00:51:16 2009
New Revision: 42588
URL: https://trac.parrot.org/parrot/changeset/42588

Log:
Do a little refactoring in Linux hints file and add a steps test file for that.

Added:
   trunk/t/steps/init/hints/linux-01.t   (contents, props changed)
      - copied, changed from r42584, trunk/t/steps/init/hints/darwin-01.t
Modified:
   trunk/MANIFEST
   trunk/config/init/hints/linux.pm

Modified: trunk/MANIFEST
==============================================================================
--- trunk/MANIFEST	Fri Nov 20 00:45:05 2009	(r42587)
+++ trunk/MANIFEST	Fri Nov 20 00:51:16 2009	(r42588)
@@ -1,7 +1,7 @@
 # ex: set ro:
 # $Id$
 #
-# generated by tools/dev/mk_manifest_and_skip.pl Thu Nov 19 00:38:23 2009 UT
+# generated by tools/dev/mk_manifest_and_skip.pl Fri Nov 20 00:17:56 2009 UT
 #
 # See below for documentation on the format of this file.
 #
@@ -2039,6 +2039,7 @@
 t/steps/init/headers-01.t                                   [test]
 t/steps/init/hints-01.t                                     [test]
 t/steps/init/hints/darwin-01.t                              [test]
+t/steps/init/hints/linux-01.t                               [test]
 t/steps/init/install-01.t                                   [test]
 t/steps/init/manifest-01.t                                  [test]
 t/steps/init/optimize-01.t                                  [test]

Modified: trunk/config/init/hints/linux.pm
==============================================================================
--- trunk/config/init/hints/linux.pm	Fri Nov 20 00:45:05 2009	(r42587)
+++ trunk/config/init/hints/linux.pm	Fri Nov 20 00:51:16 2009	(r42588)
@@ -36,75 +36,11 @@
 
         # Intel C++ compiler has the same name as its C compiler
         $link = $cc;
-
-        # suppress sprintf warnings that don't apply
-        $ccflags .= ' -wd269';
-
-        # suppress remarks about floating point comparisons
-        $ccflags .= ' -wd1572';
-
-        # suppress remarks about hiding of parameter declarations
-        $ccflags .= ' -wd1599';
-
-        # suppress remarks about "argument is incompatible with corresponding
-        # format string conversion"
-        $ccflags .= ' -wd181';
-
-        # gcc is currently not looking for unused variables, so should icc
-        # for the time being (this will reduce the noise somewhat)
-        $ccflags .= ' -wd869';
-
-        # ignore "operands are evaluated in unspecified order" warning
-        $ccflags .= ' -wd981';
-
-        # ignore "external declaration in primary source file"
-        # (only done temporarily to reduce noise)
-        $ccflags .= ' -wd1419';
-
-        # ignore "function 'xxx' was declared but never referenced"
-        # (only done temporarily to reduce noise)
-        $ccflags .= ' -wd117';
-
-        # ignore "conversion from "" to "" may lose significant bits"
-        # warnings (only done temporarily to reduce noise)
-        $ccflags .= ' -wd810';
-
-        # ignore "function "" was declared but never referenced"
-        # warnings (only done temporarily to reduce noise)
-        $ccflags .= ' -wd177';
-
-        # ignore warnings springing from problems with computed goto
-        # statements.  If someone can find out how to make icc play nicely
-        # in these situations, that would be good.
-        $ccflags .= ' -wd1296';
-
-        $ccflags .= ' -Wall -Wcheck -w2';
-
-        $ccflags .= ' -Wabi';
-        $ccflags .= ' -Wcomment';
-        $ccflags .= ' -Wdeprecated';
-        $ccflags .= ' -Wmain';
-        $ccflags .= ' -Wmissing-prototypes';
-
-        #$ccflags .= ' -Wp64';
-        $ccflags .= ' -Wpointer-arith';
-        $ccflags .= ' -Wreturn-type';
-        $ccflags .= ' -Wstrict-prototypes';
-
-        #$ccflags .= ' -Wtrigraphs';
-        $ccflags .= ' -Wuninitialized';
-        $ccflags .= ' -Wunknown-pragmas';
-        $ccflags .= ' -Wunused-function';
-        $ccflags .= ' -Wunused-variable';
-
-        # enable correct floating point behavior
-        # which is *not* the default behavior. ahem.
-        $ccflags .= ' -we147';
-
         $ld_share_flags = ' -shared -g -pipe -fexceptions -fPIC';
         $cc_shared .= ' -fPIC';
 
-        $verbose and print " ccflags: $ccflags\n";
+        $ccflags = _handle_icc_ccflags($ccflags, $verbose);
+
     }
     elsif ( $cc =~ /suncc/ ) {
         $link = 'sunCC';
@@ -159,6 +95,77 @@
     return;
 }
 
+sub _handle_icc_ccflags {
+    my ($ccflags, $verbose) = @_;
+
+    # suppress sprintf warnings that don't apply
+    $ccflags .= ' -wd269';
+
+    # suppress remarks about floating point comparisons
+    $ccflags .= ' -wd1572';
+
+    # suppress remarks about hiding of parameter declarations
+    $ccflags .= ' -wd1599';
+
+    # suppress remarks about "argument is incompatible with corresponding
+    # format string conversion"
+    $ccflags .= ' -wd181';
+
+    # gcc is currently not looking for unused variables, so should icc
+    # for the time being (this will reduce the noise somewhat)
+    $ccflags .= ' -wd869';
+
+    # ignore "operands are evaluated in unspecified order" warning
+    $ccflags .= ' -wd981';
+
+    # ignore "external declaration in primary source file"
+    # (only done temporarily to reduce noise)
+    $ccflags .= ' -wd1419';
+
+    # ignore "function 'xxx' was declared but never referenced"
+    # (only done temporarily to reduce noise)
+    $ccflags .= ' -wd117';
+
+    # ignore "conversion from "" to "" may lose significant bits"
+    # warnings (only done temporarily to reduce noise)
+    $ccflags .= ' -wd810';
+
+    # ignore "function "" was declared but never referenced"
+    # warnings (only done temporarily to reduce noise)
+    $ccflags .= ' -wd177';
+
+    # ignore warnings springing from problems with computed goto
+    # statements.  If someone can find out how to make icc play nicely
+    # in these situations, that would be good.
+    $ccflags .= ' -wd1296';
+
+    $ccflags .= ' -Wall -Wcheck -w2';
+
+    $ccflags .= ' -Wabi';
+    $ccflags .= ' -Wcomment';
+    $ccflags .= ' -Wdeprecated';
+    $ccflags .= ' -Wmain';
+    $ccflags .= ' -Wmissing-prototypes';
+
+    #$ccflags .= ' -Wp64';
+    $ccflags .= ' -Wpointer-arith';
+    $ccflags .= ' -Wreturn-type';
+    $ccflags .= ' -Wstrict-prototypes';
+
+    #$ccflags .= ' -Wtrigraphs';
+    $ccflags .= ' -Wuninitialized';
+    $ccflags .= ' -Wunknown-pragmas';
+    $ccflags .= ' -Wunused-function';
+    $ccflags .= ' -Wunused-variable';
+
+    # enable correct floating point behavior
+    # which is *not* the default behavior. ahem.
+    $ccflags .= ' -we147';
+
+    $verbose and print " ccflags: $ccflags\n";
+    return $ccflags;
+}
+
 1;
 
 # Local Variables:

Copied and modified: trunk/t/steps/init/hints/linux-01.t (from r42584, trunk/t/steps/init/hints/darwin-01.t)
==============================================================================
--- trunk/t/steps/init/hints/darwin-01.t	Thu Nov 19 17:29:40 2009	(r42584, copy source)
+++ trunk/t/steps/init/hints/linux-01.t	Fri Nov 20 00:51:16 2009	(r42588)
@@ -1,19 +1,19 @@
 #! perl
 # Copyright (C) 2009, Parrot Foundation.
 # $Id$
-# init/hints/darwin-01.t
+# init/hints/linux-01.t
 
 use strict;
 use warnings;
 use Cwd;
 use File::Temp qw( tempdir );
 use Test::More;
-plan( skip_all => 'only needs testing on Darwin' ) unless $^O =~ /darwin/i;
-plan( tests =>  36 );
+plan( skip_all => 'only needs testing on Linux' ) unless $^O =~ /linux/i;
+plan( tests =>   6 );
 
 use lib qw( lib t/configure/testlib );
 use_ok('config::init::hints');
-use_ok('config::init::hints::darwin');
+use_ok('config::init::hints::linux');
 use Parrot::Configure::Options qw( process_options );
 use Parrot::Configure::Step::Test;
 use Parrot::Configure::Test qw(
@@ -34,359 +34,27 @@
 
 ##### Tests of some internal subroutines #####
 
-##### _precheck() #####
+##### _handle_icc_ccflags() #####
 
-my $problematic_flag = 'ccflags';
-my $stored = $conf->data->get($problematic_flag);
+my $ccflags = '';
+my $verbose = 0;
+$ccflags = init::hints::linux::_handle_icc_ccflags($ccflags, $verbose);
+like( $ccflags, qr/\s-wd269/, "On icc, 'cc_flags' set as expected" );
 
+$ccflags = '';
+$verbose = 1;
 {
     my ($stdout, $stderr);
     capture(
-        sub { init::hints::darwin::_precheck(
-            $problematic_flag, $stored, 0
-        ) },
+        sub { $ccflags =
+            init::hints::linux::_handle_icc_ccflags($ccflags, $verbose); },
         \$stdout,
         \$stderr,
     );
-    ok( ! $stdout, "_precheck():  Non-verbose mode produced no output" );
-}
-
-{
-    my ($stdout, $stderr);
-    capture(
-        sub { init::hints::darwin::_precheck(
-            $problematic_flag, $stored, 1
-        ) },
-        \$stdout,
-        \$stderr,
-    );
-    ok( $stdout, "_precheck():  Verbose mode produced output" );
-    like($stdout, qr/Checking\s+$problematic_flag/,
-        "_precheck():  Got expected verbose output" );
-    like($stdout, qr/Pre-check:\s+$stored/,
-        "_precheck():  Got expected verbose output" );
-}
-
-{
-    my ($stdout, $stderr);
-    capture(
-        sub { init::hints::darwin::_precheck(
-            $problematic_flag, q{}, 1
-        ) },
-        \$stdout,
-        \$stderr,
-    );
-    ok( $stdout, "_precheck():  Verbose mode produced output" );
-    like($stdout, qr/Checking\s+$problematic_flag/,
-        "_precheck():  Got expected verbose output" );
-    like($stdout, qr/Pre-check:\s+\(nil\)/,
-        "_precheck():  Got expected verbose output" );
-}
-
-##### _strip_arch_flags_engine #####
-
-{
-    my %defaults = (
-        architectures   => [ qw( i386 ppc64 ppc x86_64 ) ],
-    );
-    my $flagsref = {};
-    my $stored = q{-someflag  -arch i386 -someotherflag -arch ppc};
-    my $flag = q{ccflags};
-    $flagsref = init::hints::darwin::_strip_arch_flags_engine(
-      $defaults{architectures}, $stored, $flagsref, $flag
-    );
-    like(
-        $flagsref->{$flag}, 
-        qr{-someflag -someotherflag},
-        "_strip_arch_flags_engine(): '-arch' flags and extra whitespace removed",
-    );
-
-
-}
-
-##### _postcheck #####
-
-{
-    my $flag = 'ccflags';
-    my $flagsref = { 'ccflags' => 'my ccflag' };
-    my ($stdout, $stderr);
-
-    capture(
-        sub { init::hints::darwin::_postcheck(
-            $flagsref, $flag, 0
-        ) },
-        \$stdout,
-        \$stderr,
-    );
-    ok( ! $stdout, "_postcheck():  Non-verbose mode produced no output" );
-
-    capture(
-        sub { init::hints::darwin::_postcheck(
-            $flagsref, $flag, 1
-        ) },
-        \$stdout,
-        \$stderr,
-    );
-    ok( $stdout, "_postcheck():  Verbose mode produced output" );
-    like($stdout, qr/Post-check:\s+$flagsref->{$flag}/,
-        "_postcheck():  Got expected verbose output" );
-
-    $flagsref = { 'ccflags' => undef };
-    capture(
-        sub { init::hints::darwin::_postcheck(
-            $flagsref, $flag, 1
-        ) },
-        \$stdout,
-        \$stderr,
-    );
-    ok( $stdout, "_postcheck():  Verbose mode produced output" );
-    like($stdout, qr/Post-check:\s+\(nil\)/,
-        "_postcheck():  Got expected verbose output" );
-}
-
-##### _strip_arch_flags #####
-
-{
-    my %defaults = (
-        problem_flags   => [ qw( ccflags ldflags ) ],
-        architectures   => [ qw( i386 ppc64 ppc x86_64 ) ],
-    );
-    my $flagsref = {};
-    my $flag = q{ccflags};
-    my $oldflag = $conf->data->get( $flag );
-
-    my $stored = q{-someflag  -arch i386 -someotherflag -arch ppc};
-    $conf->data->set( $flag => $stored );
-
-    $flagsref = init::hints::darwin::_strip_arch_flags($conf, 0);
-    like($flagsref->{$flag},
-        qr/-someflag -someotherflag/,
-        "_strip_arch_flags(): '-arch' flags and extra whitespace removed",
-    );    
-
-    my ($stdout, $stderr);
-    capture(
-        sub {
-            $flagsref = init::hints::darwin::_strip_arch_flags($conf, 1);
-        },
-        \$stdout,
-        \$stderr,
-    );
-    like($flagsref->{$flag},
-        qr/-someflag -someotherflag/,
-        "_strip_arch_flags(): '-arch' flags and extra whitespace removed",
-    );
-    like(
-        $stdout,
-        qr/Stripping -arch flags due to Apple multi-architecture build problems:/,
-        "_strip_arch_flags(): Got expected verbose output",
-    );
-
-    $flag = q{ccflags};
-    $conf->data->set( $flag => undef );
-    $flagsref = init::hints::darwin::_strip_arch_flags($conf, 0);
-    is( $flagsref->{$flag}, q{},
-        "_strip_arch_flags():  Got empty flag when expected" );
-
-    $conf->data->set( $flag => $oldflag );
-}
-
-##### _strip_ldl_as_needed #####
-
-{
-    my $oldflag = $conf->data->get( 'libs ' );
-    my ( $major, $libs );
-
-    $major = '7.99.11';
-    local $init::hints::darwin::defaults{uname} = $major;
-    $conf->data->set( libs => '-somelib -ldl -someotherlib' );
-    $libs = init::hints::darwin::_strip_ldl_as_needed(
-        $conf->data->get( 'libs' )
-    );
-    like( $libs, qr/-somelib\s+-someotherlib/,
-        "_strip_ldl_as_needed(): '-ldl' stripped as expected" );
-
-    $major = '6.99.11';
-    local $init::hints::darwin::defaults{uname} = $major;
-    $conf->data->set( libs => '-somelib -ldl -someotherlib' );
-    $libs = init::hints::darwin::_strip_ldl_as_needed(
-        $conf->data->get( 'libs' )
-    );
-    like( $libs, qr/-somelib\s+-ldl\s+-someotherlib/,
-        "_strip_ldl_as_needed(): '-ldl' not stripped as expected in older darwin" );
-
-    $conf->data->set( libs => $oldflag );
-}
-
-##### _set_deployment_environment() #####
-
-{
-    my $predicted = '10.99';
-    local $ENV{'MACOSX_DEPLOYMENT_TARGET'} = undef;
-    no warnings 'once';
-    local $init::hints::darwin::defaults{sw_vers} = qq{$predicted.11};
-    use warnings;
-    init::hints::darwin::_set_deployment_environment();
-    is($ENV{'MACOSX_DEPLOYMENT_TARGET'}, $predicted,
-        "_set_deployment_environment(): MACOSX_DEPLOYMENT_TARGET set as expected");
-}
-
-##### _probe_for_fink() #####
-
-{
-    my $tdir = tempdir( CLEANUP => 1 );
-    chdir $tdir or die "Unable to change to temporary directory: $!";
-
-    local $init::hints::darwin::defaults{fink_conf} = qq{$tdir/fink.conf};
-    ok( ! defined( init::hints::darwin::_probe_for_fink( $conf ) ),
-        "_probe_for_fink(): returned undefined value for no config file" );
-    $conf->options->set( 'verbose' => 1 );
-    {
-        my ($stdout, $stderr);
-        capture(
-            sub { init::hints::darwin::_probe_for_fink( $conf ); },
-            \$stdout,
-            \$stderr,
-        );
-        like( $stdout, qr/Fink configuration file not located/,
-            "Got expected verbose output when Fink config not located" );
-    }
-    $conf->options->set( 'verbose' => 0 );
-
-    my $fink_conf_file = q{fink.conf};
-    open my $CONF, '>', $fink_conf_file
-        or die "Unable to open $fink_conf_file for writing: $!";
-    print $CONF "Hello, world, but no Fink info\n";
-    close $CONF or die "Unable to close $fink_conf_file after writing: $!";
-    ok( ! defined( init::hints::darwin::_probe_for_fink( $conf ) ),
-        "_probe_for_fink(): returned undefined value for defective config file" );
-
-    $conf->options->set( 'verbose' => 1 );
-    {
-        my ($stdout, $stderr);
-        capture(
-            sub { init::hints::darwin::_probe_for_fink( $conf ); },
-            \$stdout,
-            \$stderr,
-        );
-        like( $stdout, qr/Fink configuration file defective/,
-            "Got expected verbose output when Fink config was defective" );
-    }
-    $conf->options->set( 'verbose' => 0 );
-
-    my $other = qq{$tdir/other_fink.conf};
-    local $init::hints::darwin::defaults{fink_conf} = $other;
-    $fink_conf_file = $other;
-    open my $OCONF, '>', $fink_conf_file
-        or die "Unable to open $fink_conf_file for writing: $!";
-    print $OCONF "Basepath:  /tmp/foobar\n";
-    close $OCONF or die "Unable to close $fink_conf_file after writing: $!";
-    ok( ! defined( init::hints::darwin::_probe_for_fink( $conf ) ),
-        "_probe_for_fink(): returned undefined value for missing directories" );
-
-    $conf->options->set( 'verbose' => 1 );
-    {
-        my ($stdout, $stderr);
-        capture(
-            sub { init::hints::darwin::_probe_for_fink( $conf ); },
-            \$stdout,
-            \$stderr,
-        );
-        like( $stdout, qr/Could not locate Fink directories/,
-            "Got expected verbose output when Fink directories were missing" );
-    }
-    $conf->options->set( 'verbose' => 0 );
-
-    chdir $cwd or die "Unable to change back to starting directory: $!";
-}
-
-##### _probe_for_macports() #####
-
-{
-    my $tdir = tempdir( CLEANUP => 1 );
-    chdir $tdir or die "Unable to change to temporary directory: $!";
-
-    local $init::hints::darwin::defaults{ports_base_dir} = qq{$tdir/foobar};
-    ok( ! defined( init::hints::darwin::_probe_for_macports( $conf ) ),
-        "_probe_for_macports(): returned undefined value for no config file" );
-
-    $conf->options->set( 'verbose' => 1 );
-    {
-        my ($stdout, $stderr);
-        capture(
-            sub { init::hints::darwin::_probe_for_macports( $conf ); },
-            \$stdout,
-            \$stderr,
-        );
-        like( $stdout, qr/Could not locate Macports directories/,
-            "Got expected verbose output when Macports directories not found" );
-    }
-    $conf->options->set( 'verbose' => 0 );
-}
-
-##### _probe_for_libraries() #####
-
-{
-    $conf->options->set( 'darwin_no_fink' => 1 );
-    $conf->options->set( 'verbose' => 0 );
-    my $lib_dir = $conf->data->get('build_dir') . "/blib/lib";
-    my $flagsref = {};
-    $flagsref->{ldflags} .= " -L$lib_dir";
-    $flagsref->{ccflags} .= " -pipe -fno-common -Wno-long-double ";
-    $flagsref->{linkflags} .= " -undefined dynamic_lookup";
-    my %state_before = map { $_ => $flagsref->{$_} } keys %{ $flagsref };
-    ok( ! defined ( init::hints::darwin::_probe_for_libraries(
-        $conf, $flagsref, 'fink')
-    ), "_probe_for_libraries() returned undef as expected" );
-    is_deeply( $flagsref, { %state_before },
-        "No change in flags, as expected" );
-
-    $conf->options->set( 'darwin_no_fink' => 0 );
-}
-
-##### _add_to_flags() #####
-
-{
-    my ( $addl_flags_ref, $flagsref, $title, $verbose );
-    $addl_flags_ref = undef;
-    $flagsref = undef;
-    $title = 'Fink';
-    $verbose = 0;
-    ok( init::hints::darwin::_add_to_flags(
-        $addl_flags_ref, $flagsref, $title, $verbose
-    ), "_add_to_flags(): returned true value when no probes found" );
-
-    $verbose = 1;
-    {
-        my ($stdout, $stderr);
-        capture(
-            sub { init::hints::darwin::_add_to_flags(
-                $addl_flags_ref, $flagsref, $title, $verbose
-            ); },
-            \$stdout,
-            \$stderr,
-        );
-        like( $stdout, qr/Probe for $title unsuccessful/,
-            "_add_to_flags(): got expected verbose output when probe unsuccessful" );
-    }
-
-    $addl_flags_ref = {
-        ldflags   => "-Lfink_lib_dir",
-        ccflags   => "-Lfink_include_dir",
-        linkflags => "-Lfink_lib_dir",
-    };
-    my $lib_dir = $conf->data->get('build_dir') . "/blib/lib";
-    $flagsref = undef;
-    $flagsref->{ldflags} = " -L$lib_dir";
-    $flagsref->{ccflags} = " -pipe -fno-common -Wno-long-double ";
-    $flagsref->{linkflags} = undef;
-    $title = 'Fink';
-    $verbose = 0;
-    my $rv = init::hints::darwin::_add_to_flags(
-        $addl_flags_ref, $flagsref, $title, $verbose
-    );
-    is( $flagsref->{linkflags}, " $addl_flags_ref->{linkflags}",
-        "_add_to_flags():  flag added where not previously populated" );
+    like( $ccflags, qr/\s-wd269/, "On icc, 'cc_flags' set as expected" );
+    like( $stdout,
+        qr/\sccflags:.*?-wd269/,
+        "On icc, got expected verbose output for 'cc_flags'" );
 }
 
 pass("Completed all tests in $0");
@@ -395,17 +63,17 @@
 
 =head1 NAME
 
-init/hints/darwin-01.t - test init::hints::darwin
+init/hints/linux-01.t - test init::hints::linux
 
 =head1 SYNOPSIS
 
-    % prove t/steps/init/hints/darwin-01.t
+    % prove t/steps/init/hints/linux-01.t
 
 =head1 DESCRIPTION
 
 The files in this directory test functionality used by F<Configure.pl>.
 
-The tests in this file test init::hints::darwin.
+The tests in this file test init::hints::linux.
 
 =head1 AUTHOR
 
@@ -413,7 +81,7 @@
 
 =head1 SEE ALSO
 
-config::init::hints::darwin, F<Configure.pl>.
+config::init::hints::linux, F<Configure.pl>.
 
 =cut
 


More information about the parrot-commits mailing list