Author: jkeenan Date: Mon Nov 5 17:32:38 2007 New Revision: 22731 Added: trunk/t/configure/124-auto_alignptrs-02.t (contents, props changed) trunk/t/configure/124-auto_alignptrs-03.t (contents, props changed) trunk/t/configure/124-auto_alignptrs-04.t (contents, props changed) trunk/t/configure/124-auto_alignptrs-05.t (contents, props changed) Modified: trunk/MANIFEST trunk/config/auto/alignptrs.pm
Log: Committing patch submitted in https://rt.perl.org/rt3/Ticket/Display.html?id=43345. Some refactoring; extensive unit testing. Modified: trunk/MANIFEST ============================================================================== --- trunk/MANIFEST (original) +++ trunk/MANIFEST Mon Nov 5 17:32:38 2007 @@ -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 23:56:36 2007 UT # # See tools/dev/install_files.pl for documentation on the # format of this file. @@ -3063,6 +3063,10 @@ t/configure/122-auto_ops.t [] t/configure/123-auto_pmc.t [] t/configure/124-auto_alignptrs-01.t [] +t/configure/124-auto_alignptrs-02.t [] +t/configure/124-auto_alignptrs-03.t [] +t/configure/124-auto_alignptrs-04.t [] +t/configure/124-auto_alignptrs-05.t [] t/configure/125-auto_headers-01.t [] t/configure/126-auto_sizes-01.t [] t/configure/127-auto_byteorder-01.t [] Modified: trunk/config/auto/alignptrs.pm ============================================================================== --- trunk/config/auto/alignptrs.pm (original) +++ trunk/config/auto/alignptrs.pm Mon Nov 5 17:32:38 2007 @@ -39,18 +39,18 @@ return 1; } - $self->set_result(''); + my $result_str = ''; my $align; if ( defined( $conf->data->get('ptr_alignment') ) ) { $align = $conf->data->get('ptr_alignment'); - $self->set_result("configured: "); + $result_str .= "configured: "; } elsif ( $^O eq 'hpux' && $Config{ccflags} !~ /DD64/ ) { # HP-UX 10.20/32 hangs in this test. $align = 4; $conf->data->set( ptr_alignment => $align ); - $self->set_result("for hpux: "); + $result_str .= "for hpux: "; } else { @@ -69,8 +69,9 @@ $conf->data->set( ptr_alignment => $align ); } - $self->set_result( $self->result . " $align byte" ); - $self->set_result( $self->result . 's' ) unless $align == 1; + $result_str .= " $align byte"; + $result_str .= "s" unless $align == 1; + $self->set_result($result_str); return 1; } Added: trunk/t/configure/124-auto_alignptrs-02.t ============================================================================== --- (empty file) +++ trunk/t/configure/124-auto_alignptrs-02.t Mon Nov 5 17:32:38 2007 @@ -0,0 +1,82 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 124-auto_alignptrs-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::alignptrs'); +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::alignptrs}; + +$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 $align = 1; +$conf->data->set('ptr_alignment' => $align); +my $ret = $step->runstep($conf); +ok( $ret, "$step_name runstep() returned true value" ); +is($step->result(), qq{configured: $align byte}, "Expected result was set"); + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +124-auto_alignptrs-02.t - test config::auto::alignptrs + +=head1 SYNOPSIS + + % prove t/configure/124-auto_alignptrs-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::alignptrs. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::alignptrs, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Added: trunk/t/configure/124-auto_alignptrs-03.t ============================================================================== --- (empty file) +++ trunk/t/configure/124-auto_alignptrs-03.t Mon Nov 5 17:32:38 2007 @@ -0,0 +1,82 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 124-auto_alignptrs-03.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::alignptrs'); +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::alignptrs}; + +$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 $align = 2; +$conf->data->set('ptr_alignment' => $align); +my $ret = $step->runstep($conf); +ok( $ret, "$step_name runstep() returned true value" ); +is($step->result(), qq{configured: $align bytes}, "Expected result was set"); + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +124-auto_alignptrs-03.t - test config::auto::alignptrs + +=head1 SYNOPSIS + + % prove t/configure/124-auto_alignptrs-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::alignptrs. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::alignptrs, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Added: trunk/t/configure/124-auto_alignptrs-04.t ============================================================================== --- (empty file) +++ trunk/t/configure/124-auto_alignptrs-04.t Mon Nov 5 17:32:38 2007 @@ -0,0 +1,92 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 124-auto_alignptrs-04.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::alignptrs'); +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::alignptrs}; + +$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" ); + +{ + use Config; + local $^O = q{hpux}; + my $ret = $step->runstep($conf); + ok( $ret, "$step_name runstep() returned true value" ); + if ( $Config{ccflags} !~ /DD64/ ) { + is($conf->data->get('ptr_alignment'), 4, + "Got expected pointer alignment for HP Unix"); + is($step->result(), qq{for hpux: 4 bytes}, + "Expected result was set"); + } else { + pass("Cannot mock %Config"); + pass("Cannot mock %Config"); + } +} + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +124-auto_alignptrs-04.t - test config::auto::alignptrs + +=head1 SYNOPSIS + + % prove t/configure/124-auto_alignptrs-04.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::alignptrs. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::alignptrs, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Added: trunk/t/configure/124-auto_alignptrs-05.t ============================================================================== --- (empty file) +++ trunk/t/configure/124-auto_alignptrs-05.t Mon Nov 5 17:32:38 2007 @@ -0,0 +1,90 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 124-auto_alignptrs-05.t + +use strict; +use warnings; +use Test::More qw(no_plan); # tests => 13; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::alignptrs'); +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::alignptrs}; + +$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" ); + +{ + $conf->data->set('ptr_alignment' => undef); + if ($^O eq q{hpux}) { $^O = q{linux} } + my $ret; + eval { $ret = $step->runstep($conf); }; + if ($@) { + like($@, qr/Can't determine alignment/, + "Got expected error message when runstep() failed"); + } else { + like($step->result(), qr/bytes?/, + "Expected result was set"); + } +} + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +124-auto_alignptrs-05.t - test config::auto::alignptrs + +=head1 SYNOPSIS + + % prove t/configure/124-auto_alignptrs-05.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::alignptrs. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::alignptrs, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: