Author: jkeenan Date: Wed Nov 14 15:43:23 2007 New Revision: 22832 Added: trunk/t/configure/125-auto_headers-02.t (contents, props changed) trunk/t/configure/125-auto_headers-03.t (contents, props changed) trunk/t/configure/125-auto_headers-04.t (contents, props changed) Modified: trunk/MANIFEST trunk/config/auto/headers.pm trunk/t/configure/125-auto_headers-01.t
Log: config::auto::headers: Applying patches submitted to RT in https://rt.perl.org/rt3/Ticket/Display.html?id=43324. Refactoring of config step class to increase testability. Additional test files. Modified: trunk/MANIFEST ============================================================================== --- trunk/MANIFEST (original) +++ trunk/MANIFEST Wed Nov 14 15:43:23 2007 @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Wed Nov 14 03:10:35 2007 UT +# generated by tools/dev/mk_manifest_and_skip.pl Wed Nov 14 03:59:48 2007 UT # # See tools/dev/install_files.pl for documentation on the # format of this file. @@ -3070,6 +3070,9 @@ t/configure/124-auto_alignptrs-04.t [] t/configure/124-auto_alignptrs-05.t [] t/configure/125-auto_headers-01.t [] +t/configure/125-auto_headers-02.t [] +t/configure/125-auto_headers-03.t [] +t/configure/125-auto_headers-04.t [] t/configure/126-auto_sizes-01.t [] t/configure/127-auto_byteorder-01.t [] t/configure/127-auto_byteorder-02.t [] Modified: trunk/config/auto/headers.pm ============================================================================== --- trunk/config/auto/headers.pm (original) +++ trunk/config/auto/headers.pm Wed Nov 14 15:43:23 2007 @@ -39,36 +39,10 @@ $self->set_result('skipped'); return 1; } + _set_from_Config($conf, \%Config); - # perl5's Configure system doesn't call this by its full name, which may - # confuse use later, particularly once we break free and start doing all - # probing ourselves - my %mapping = ( i_niin => "i_netinetin" ); + my @extra_headers = _list_extra_headers(); - for ( keys %Config ) { - next unless /^i_/; - $conf->data->set( $mapping{$_} || $_ => $Config{$_} ); - } - - # some headers may not be probed-for by perl 5, or might not be - # properly reflected in %Config (i_fcntl seems to be wrong on my machine, - # for instance). - # - # FreeBSD wants this order: - #include <sys/types.h> - #include <sys/socket.h> - #include <netinet/in.h> - #include <arpa/inet.h> - # hence add sys/types.h to the reprobe list, and have 2 goes at getting - # the header. - my @extra_headers = qw(malloc.h fcntl.h setjmp.h pthread.h signal.h - sys/types.h sys/socket.h netinet/in.h arpa/inet.h - sys/stat.h sysexit.h limits.h); - - # more extra_headers needed on mingw/msys; *BSD fails if they are present - if ( $^O eq "msys" ) { - push @extra_headers, qw(sysmman.h netdb.h); - } my @found_headers; foreach my $header (@extra_headers) { my $pass = 0; @@ -78,7 +52,8 @@ # work on *BSD where some headers are documented as relying on others # being included first. foreach my $use_headers ( [$header], [ @found_headers, $header ] ) { - $conf->data->set( testheaders => join( '', map { "#include <$_>\n" } @$use_headers ) ); + $conf->data->set( testheaders => + join( '', map { "#include <$_>\n" } @$use_headers ) ); $conf->data->set( testheader => $header ); cc_gen('config/auto/headers/test_c.in'); @@ -105,6 +80,43 @@ return 1; } +sub _set_from_Config { + my ($conf, $Configref) = @_; + # perl5's Configure system doesn't call this by its full name, which may + # confuse use later, particularly once we break free and start doing all + # probing ourselves + my %mapping = ( i_niin => "i_netinetin" ); + + for ( keys %{$Configref} ) { + next unless /^i_/; + $conf->data->set( $mapping{$_} || $_ => $Configref->{$_} ); + } +} + +sub _list_extra_headers { + # some headers may not be probed-for by perl 5, or might not be + # properly reflected in %Config (i_fcntl seems to be wrong on my machine, + # for instance). + # + # FreeBSD wants this order: + #include <sys/types.h> + #include <sys/socket.h> + #include <netinet/in.h> + #include <arpa/inet.h> + # hence add sys/types.h to the reprobe list, and have 2 goes at getting + # the header. + my @extra_headers = qw(malloc.h fcntl.h setjmp.h pthread.h signal.h + sys/types.h sys/socket.h netinet/in.h arpa/inet.h + sys/stat.h sysexit.h limits.h); + + # more extra_headers needed on mingw/msys; *BSD fails if they are present + if ( $^O eq "msys" ) { + push @extra_headers, qw(sysmman.h netdb.h); + } + return @extra_headers; +} + + 1; # Local Variables: Modified: trunk/t/configure/125-auto_headers-01.t ============================================================================== --- trunk/t/configure/125-auto_headers-01.t (original) +++ trunk/t/configure/125-auto_headers-01.t Wed Nov 14 15:43:23 2007 @@ -60,7 +60,8 @@ The files in this directory test functionality used by F<Configure.pl>. -The tests in this file test subroutines exported by config::auto::headers. +The tests in this file test config::auto::headers with the C<miniparrot> +option set. =head1 AUTHOR Added: trunk/t/configure/125-auto_headers-02.t ============================================================================== --- (empty file) +++ trunk/t/configure/125-auto_headers-02.t Wed Nov 14 15:43:23 2007 @@ -0,0 +1,82 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 125-auto_headers-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::headers'); +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::headers}; + +$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" ); +is($step->result(), q{}, "Result is empty string as expected"); + +pass("Keep Devel::Cover happy"); +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +125-auto_headers-02.t - test config::auto::headers + +=head1 SYNOPSIS + + % prove t/configure/125-auto_headers-02.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test config::auto::headers in its most typical +case. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::headers, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Added: trunk/t/configure/125-auto_headers-03.t ============================================================================== --- (empty file) +++ trunk/t/configure/125-auto_headers-03.t Wed Nov 14 15:43:23 2007 @@ -0,0 +1,91 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 125-auto_headers-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::headers'); +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 $pkg = q{auto::headers}; + +$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 $tie_out = tie *STDOUT, "Parrot::IO::Capture::Mini" + or croak "Unable to tie"; + my $ret = $step->runstep($conf); + my @more_lines = $tie_out->READLINE; + ok( @more_lines, "verbose output captured" ); + ok( $ret, "$step_name runstep() returned true value" ); + is($step->result(), q{}, "Result is empty string as expected"); + +} +untie *STDOUT; + +pass("Keep Devel::Cover happy"); +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +125-auto_headers-03.t - test config::auto::headers + +=head1 SYNOPSIS + + % prove t/configure/125-auto_headers-03.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test config::auto::headers with the C<verbose> +option set. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::headers, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Added: trunk/t/configure/125-auto_headers-04.t ============================================================================== --- (empty file) +++ trunk/t/configure/125-auto_headers-04.t Wed Nov 14 15:43:23 2007 @@ -0,0 +1,90 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 125-auto_headers-04.t + +use strict; +use warnings; +use Test::More tests => 15; +use Carp; +use Config; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::headers'); +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 => [ ], + mode => q{configure}, + } +); + +my $conf = Parrot::Configure->new; + +test_step_thru_runstep( $conf, q{init::defaults}, $args ); + +my $pkg = q{auto::headers}; + +$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" ); + +auto::headers::_set_from_Config($conf, \%Config); +ok($conf->data->get('i_netinetin'), "Mapping made correctly"); +ok(! $conf->data->get('i_niin'), "Mapping made correctly"); + +{ + local $^O = "msys"; + my %extra_headers = map {$_, 1} auto::headers::_list_extra_headers(); + ok($extra_headers{'sysmman.h'}, "Special header set for msys"); + ok($extra_headers{'netdb.h'}, "Special header set for msys"); +} + +pass("Keep Devel::Cover happy"); +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +125-auto_headers-04.t - test config::auto::headers + +=head1 SYNOPSIS + + % prove t/configure/125-auto_headers-04.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file test subroutines internal to config::auto::headers. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::headers, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: