From 4e3504ea398d52404f1383ea353d6653851e98f6 Mon Sep 17 00:00:00 2001 From: jkeenan Date: Mon, 24 Dec 2007 21:12:29 +0000 Subject: [PATCH] auto::funcptr: Refactor code out of runstep() into _cast_void_pointers_msg() and _set_positive_result(). Rename one test file, give it new content and add two more test files. Cf.: https://rt.perl.org/rt3/Ticket/Display.html?id=43316. git-svn-id: https://svn.perl.org/parrot/trunk@24193 d31e2699-5ff4-0310-a27c-f18f2fbe73fe --- MANIFEST | 6 ++- config/auto/funcptr.pm | 23 +++++++--- t/configure/134-auto_funcptr-01.t | 79 +++++++++++++++++++++++++++++++ t/configure/134-auto_funcptr-02.t | 97 +++++++++++++++++++++++++++++++++++++++ t/configure/134-auto_funcptr-03.t | 87 +++++++++++++++++++++++++++++++++++ t/configure/134-auto_funcptr.t | 52 --------------------- 6 files changed, 283 insertions(+), 61 deletions(-) create mode 100644 t/configure/134-auto_funcptr-01.t create mode 100644 t/configure/134-auto_funcptr-02.t create mode 100644 t/configure/134-auto_funcptr-03.t delete mode 100644 t/configure/134-auto_funcptr.t diff --git a/MANIFEST b/MANIFEST index e1f960c587..11c3e319aa 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Mon Dec 24 18:21:16 2007 UT +# generated by tools/dev/mk_manifest_and_skip.pl Mon Dec 24 20:51:53 2007 UT # # See tools/dev/install_files.pl for documentation on the # format of this file. @@ -3182,7 +3182,9 @@ t/configure/131-auto_isreg-02.t [] t/configure/131-auto_isreg-03.t [] t/configure/132-auto_jit-01.t [] t/configure/133-gen_cpu.t [] -t/configure/134-auto_funcptr.t [] +t/configure/134-auto_funcptr-01.t [] +t/configure/134-auto_funcptr-02.t [] +t/configure/134-auto_funcptr-03.t [] t/configure/135-auto_cgoto-01.t [] t/configure/135-auto_cgoto-02.t [] t/configure/135-auto_cgoto-03.t [] diff --git a/config/auto/funcptr.pm b/config/auto/funcptr.pm index f4603d76b1..5e003f65aa 100644 --- a/config/auto/funcptr.pm +++ b/config/auto/funcptr.pm @@ -40,6 +40,17 @@ sub runstep { eval { cc_build(); }; if ( $@ || cc_run() !~ /OK/ ) { + _cast_void_pointers_msg(); + exit(-1); + } + cc_clean(); + $self->_set_positive_result($conf); + } + + return 1; +} + +sub _cast_void_pointers_msg { print <<"END"; Although it is not required by the ANSI C standard, Parrot requires the ability to cast from void pointers to function @@ -52,14 +63,12 @@ to use the JIT code. If you wish to continue without JIT support, please re-run this script With the '--jitcapable=0' argument. END - exit(-1); - } - cc_clean(); - print " (yes) " if $conf->options->get('verbose'); - $self->set_result('yes'); - } +} - return 1; +sub _set_positive_result { + my ($self, $conf) = @_; + print " (yes) " if $conf->options->get('verbose'); + $self->set_result('yes'); } 1; diff --git a/t/configure/134-auto_funcptr-01.t b/t/configure/134-auto_funcptr-01.t new file mode 100644 index 0000000000..18733280ae --- /dev/null +++ b/t/configure/134-auto_funcptr-01.t @@ -0,0 +1,79 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 134-auto_funcptr-01.t + +use strict; +use warnings; +use Test::More tests => 11; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok('config::init::defaults'); +use_ok('config::auto::funcptr'); + +use Parrot::BuildUtil; +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( test_step_thru_runstep); + +my $args = process_options( { + argv => [ q{--jitcapable=0} ], + mode => q{configure}, +} ); + +my $conf = Parrot::Configure->new(); + +test_step_thru_runstep($conf, q{init::defaults}, $args); + +my ($task, $step_name, $step, $ret); +my $pkg = q{auto::funcptr}; + +$conf->add_steps($pkg); +$conf->options->set(%{$args}); + +$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"); + +$ret = $step->runstep($conf); +ok($ret, "$step_name runstep() returned defined value" ); + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +134-auto_funcptr-01.t - test config::auto::funcptr + +=head1 SYNOPSIS + + % prove t/configure/134-auto_funcptr-01.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F. + +The tests in this file test aspects of config::auto::funcptr in the case where +the C<--jitcapable> option has been set to C<0>. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::funcptr, F. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: diff --git a/t/configure/134-auto_funcptr-02.t b/t/configure/134-auto_funcptr-02.t new file mode 100644 index 0000000000..7af32aeef9 --- /dev/null +++ b/t/configure/134-auto_funcptr-02.t @@ -0,0 +1,97 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 134-auto_funcptr-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::funcptr'); + +use Parrot::BuildUtil; +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); + +my ($task, $step_name, $step, $ret); +my $pkg = q{auto::funcptr}; + +$conf->add_steps($pkg); +$conf->options->set(%{$args}); + +$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 $stdout; + my $ret = capture( + sub { auto::funcptr::_cast_void_pointers_msg(); }, + \$stdout, + ); + like($stdout, qr/Although it is not required/s, + "Got expected advisory message"); +} + +{ + my $stdout; + my $ret = capture( + sub { auto::funcptr::_set_positive_result($step, $conf); }, + \$stdout, + ); + is($step->result, q{yes}, "Got expected result"); + ok(! $stdout, "Nothing printed to STDOUT, as expected"); +} + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +134-auto_funcptr-02.t - test config::auto::funcptr + +=head1 SYNOPSIS + + % prove t/configure/134-auto_funcptr-02.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F. + +The tests in this file test aspects of config::auto::funcptr in the case where +the C<--verbose> option has not been set. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::funcptr, F. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: diff --git a/t/configure/134-auto_funcptr-03.t b/t/configure/134-auto_funcptr-03.t new file mode 100644 index 0000000000..034720f246 --- /dev/null +++ b/t/configure/134-auto_funcptr-03.t @@ -0,0 +1,87 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 134-auto_funcptr-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::funcptr'); + +use Parrot::BuildUtil; +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 => [ q{--verbose} ], + mode => q{configure}, +} ); + +my $conf = Parrot::Configure->new(); + +test_step_thru_runstep($conf, q{init::defaults}, $args); + +my ($task, $step_name, $step, $ret); +my $pkg = q{auto::funcptr}; + +$conf->add_steps($pkg); +$conf->options->set(%{$args}); + +$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 $stdout; + my $ret = capture( + sub { auto::funcptr::_set_positive_result($step, $conf); }, + \$stdout, + ); + is($step->result, q{yes}, "Got expected result"); + like($stdout, qr/yes/, "Got expected verbose output"); +} + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +134-auto_funcptr-03.t - test config::auto::funcptr + +=head1 SYNOPSIS + + % prove t/configure/134-auto_funcptr-03.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F. + +The tests in this file test config::auto::funcptr in the case where the +C<--verbose> option has been set. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +config::auto::funcptr, F. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: diff --git a/t/configure/134-auto_funcptr.t b/t/configure/134-auto_funcptr.t deleted file mode 100644 index 28cee44a22..0000000000 --- a/t/configure/134-auto_funcptr.t +++ /dev/null @@ -1,52 +0,0 @@ -#! perl -# Copyright (C) 2007, The Perl Foundation. -# $Id$ -# 134-auto_funcptr.t - -use strict; -use warnings; -use Test::More tests => 2; -use Carp; -use lib qw( lib ); -use_ok('config::auto::funcptr'); - -=for hints_for_testing Check latest reports of Parrot configuration -tools testing coverage to see where your time available for writing -tests is spent. Try to cover all branches and conditions. - -=cut - -pass("Completed all tests in $0"); - -################### DOCUMENTATION ################### - -=head1 NAME - -134-auto_funcptr.t - test config::auto::funcptr - -=head1 SYNOPSIS - - % prove t/configure/134-auto_funcptr.t - -=head1 DESCRIPTION - -The files in this directory test functionality used by F. - -The tests in this file test subroutines exported by config::auto::funcptr. - -=head1 AUTHOR - -James E Keenan - -=head1 SEE ALSO - -config::auto::funcptr, F. - -=cut - -# Local Variables: -# mode: cperl -# cperl-indent-level: 4 -# fill-column: 100 -# End: -# vim: expandtab shiftwidth=4: -- 2.11.4.GIT