The patch attached completes unit testing for Parrot configuration step auto::cgoto. The step class has been refactored slightly so that its internals are more testable. 3 additional test files have been contributed. There should be no change in functionality.
I will apply this patch in 2-3 days if there is no objection. Thank you very much. kid51
Index: MANIFEST =================================================================== --- MANIFEST (revision 22731) +++ MANIFEST (working copy) @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Mon Nov 5 23:56:36 2007 UT +# generated by tools/dev/mk_manifest_and_skip.pl Tue Nov 6 11:53:12 2007 UT # # See tools/dev/install_files.pl for documentation on the # format of this file. @@ -3082,6 +3082,9 @@ t/configure/133-gen_cpu.t [] t/configure/134-auto_funcptr.t [] t/configure/135-auto_cgoto-01.t [] +t/configure/135-auto_cgoto-02.t [] +t/configure/135-auto_cgoto-03.t [] +t/configure/135-auto_cgoto-04.t [] t/configure/136-auto_inline.t [] t/configure/137-auto_gc.t [] t/configure/138-auto_memalign-01.t [] Index: t/configure/135-auto_cgoto-02.t =================================================================== --- t/configure/135-auto_cgoto-02.t (revision 0) +++ t/configure/135-auto_cgoto-02.t (revision 0) @@ -0,0 +1,86 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 135-auto_cgoto-02.t + +use strict; +use warnings; +use Test::More tests => 18; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::cgoto'); +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::cgoto}; + +$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" ); +ok(defined($step->result()), "A result was defined"); +ok(defined($conf->data->get('TEMP_cg_h')), "An attribute has been defined"); +ok(defined($conf->data->get('TEMP_cg_c')), "An attribute has been defined"); +ok(defined($conf->data->get('TEMP_cg_o')), "An attribute has been defined"); +ok(defined($conf->data->get('TEMP_cg_r')), "An attribute has been defined"); +ok(defined($conf->data->get('cg_flag')), "An attribute has been defined"); + +pass("Keep Devel::Cover happy"); +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +135-auto_cgoto-02.t - test config::auto::cgoto + +=head1 SYNOPSIS + + % prove t/configure/135-auto_cgoto-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::cgoto. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::cgoto, 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/135-auto_cgoto-02.t ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Index: t/configure/135-auto_cgoto-03.t =================================================================== --- t/configure/135-auto_cgoto-03.t (revision 0) +++ t/configure/135-auto_cgoto-03.t (revision 0) @@ -0,0 +1,103 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 135-auto_cgoto-03.t + +use strict; +use warnings; +use Test::More tests => 26; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::cgoto'); +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::cgoto}; + +$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->options->set(cgoto => 1); +is(auto::cgoto::_probe_for_cgoto($conf->options->get('cgoto')), 1, + "Got expected return value"); +$conf->options->set(cgoto => 0); +is(auto::cgoto::_probe_for_cgoto($conf->options->get('cgoto')), 0, + "Got expected return value"); +$conf->options->set(cgoto => undef); +ok(defined(auto::cgoto::_probe_for_cgoto($conf->options->get('cgoto'))), + "Probe returned a defined value"); + +$step->_evaluate_cgoto($conf, 1); +ok($conf->data->get('TEMP_cg_h'), "An attribute was set to true value"); +ok($conf->data->get('TEMP_cg_c'), "An attribute was set to true value"); +ok($conf->data->get('TEMP_cg_o'), "An attribute was set to true value"); +ok($conf->data->get('TEMP_cg_r'), "An attribute was set to true value"); +ok($conf->data->get('cg_flag'), "An attribute was set to true value"); +is($step->result(), q{yes}, "Expected result was set"); + +$step->_evaluate_cgoto($conf, 0); +is($conf->data->get('TEMP_cg_h'), q{}, "An attribute was set to empty string"); +is($conf->data->get('TEMP_cg_c'), q{}, "An attribute was set to empty string"); +is($conf->data->get('TEMP_cg_o'), q{}, "An attribute was set to empty string"); +is($conf->data->get('TEMP_cg_r'), q{}, "An attribute was set to empty string"); +is($conf->data->get('cg_flag'), q{}, "An attribute was set to empty string"); +is($step->result(), q{no}, "Expected result was set"); + +pass("Keep Devel::Cover happy"); +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +135-auto_cgoto-03.t - test config::auto::cgoto + +=head1 SYNOPSIS + + % prove t/configure/135-auto_cgoto-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::cgoto. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::cgoto, 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/135-auto_cgoto-03.t ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Index: t/configure/135-auto_cgoto-04.t =================================================================== --- t/configure/135-auto_cgoto-04.t (revision 0) +++ t/configure/135-auto_cgoto-04.t (revision 0) @@ -0,0 +1,108 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 135-auto_cgoto-04.t + +use strict; +use warnings; +use Test::More tests => 25; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::cgoto'); +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::cgoto}; + +$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"; + $step->_evaluate_cgoto($conf, 1); + my @more_lines = $tie_out->READLINE; + ok( @more_lines, "verbose output captured" ); + ok($conf->data->get('TEMP_cg_h'), "An attribute was set to true value"); + ok($conf->data->get('TEMP_cg_c'), "An attribute was set to true value"); + ok($conf->data->get('TEMP_cg_o'), "An attribute was set to true value"); + ok($conf->data->get('TEMP_cg_r'), "An attribute was set to true value"); + ok($conf->data->get('cg_flag'), "An attribute was set to true value"); + is($step->result(), q{yes}, "Expected result was set"); +} +untie *STDOUT; + +{ + my $tie_out = tie *STDOUT, "Parrot::IO::Capture::Mini" + or croak "Unable to tie"; + $step->_evaluate_cgoto($conf, 0); + my @more_lines = $tie_out->READLINE; + ok( @more_lines, "verbose output captured" ); + is($conf->data->get('TEMP_cg_h'), q{}, "An attribute was set to empty string"); + is($conf->data->get('TEMP_cg_c'), q{}, "An attribute was set to empty string"); + is($conf->data->get('TEMP_cg_o'), q{}, "An attribute was set to empty string"); + is($conf->data->get('TEMP_cg_r'), q{}, "An attribute was set to empty string"); + is($conf->data->get('cg_flag'), q{}, "An attribute was set to empty string"); + is($step->result(), q{no}, "Expected result was set"); +} +untie *STDOUT; + +pass("Keep Devel::Cover happy"); +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +135-auto_cgoto-04.t - test config::auto::cgoto + +=head1 SYNOPSIS + + % prove t/configure/135-auto_cgoto-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::cgoto. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::cgoto, 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/135-auto_cgoto-04.t ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Index: t/configure/135-auto_cgoto-01.t =================================================================== --- t/configure/135-auto_cgoto-01.t (revision 22731) +++ t/configure/135-auto_cgoto-01.t (working copy) @@ -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 ################### Index: config/auto/cgoto.pm =================================================================== --- config/auto/cgoto.pm (revision 22731) +++ config/auto/cgoto.pm (working copy) @@ -37,8 +37,15 @@ return 1; } - my ( $cgoto, $verbose ) = $conf->options->get(qw(cgoto verbose)); + my $test = _probe_for_cgoto( $conf->options->get('cgoto') ); + $self->_evaluate_cgoto($conf, $test); + + return 1; +} + +sub _probe_for_cgoto { + my $cgoto = shift; my $test; if ( defined $cgoto ) { $test = $cgoto; @@ -48,7 +55,12 @@ $test = eval { cc_build(); 1; } || 0; cc_clean(); } + return $test; +} +sub _evaluate_cgoto { + my ($self, $conf, $test) = @_; + my $verbose = $conf->options->get('verbose'); if ($test) { $conf->data->set( TEMP_cg_h => '$(INC_DIR)/oplib/core_ops_cg.h $(INC_DIR)/oplib/core_ops_cgp.h', @@ -88,8 +100,6 @@ print " (no) " if $verbose; $self->set_result('no'); } - - return 1; } 1;