Permalink
Browse files

Further refactoring to improve testability. Statement coverage up to …

…93%, which, given that we can't directly test the C code, is as about as good as we're going to do.

git-svn-id: https://svn.parrot.org/parrot/branches/auto_frames_refactor@41440 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent a237060 commit 9330765426d4bc607857d760b8701abd88d576fe jkeenan committed Sep 24, 2009
Showing with 54 additions and 26 deletions.
  1. +27 −22 config/auto/frames.pm
  2. +27 −4 t/steps/auto/frames-01.t
View
@@ -33,6 +33,30 @@ sub runstep {
my $can_build_call_frames = _call_frames_buildable($conf);
+ $self->_handle_can_build_call_frames( $conf, $can_build_call_frames );
+
+ return 1;
+}
+
+sub _call_frames_buildable {
+ my $conf = shift;
+ my $osname = $conf->data->get('osname');
+ my $cpuarch = $conf->data->get('cpuarch');
+ my $nvsize = $conf->data->get('nvsize');
+ my $can_build_call_frames;
+
+ if (defined $conf->options->get('buildframes')) {
+ $can_build_call_frames = $conf->options->get('buildframes');
+ }
+ else {
+ $can_build_call_frames = ($nvsize == 8 && $cpuarch eq 'i386'
+ && $osname ne 'darwin');
+ }
+ return $can_build_call_frames;
+}
+
+sub _handle_can_build_call_frames {
+ my ($self, $conf, $can_build_call_frames) = @_;
if ( $can_build_call_frames ) {
$conf->data->set(
cc_build_call_frames => '-DCAN_BUILD_CALL_FRAMES',
@@ -61,34 +85,15 @@ sub runstep {
else {
$conf->data->set( has_exec_protect => 0 );
}
+ $self->set_result( 'yes' );
}
else {
- $conf->data->set(
- cc_build_call_frames => '',
- );
+ $conf->data->set( cc_build_call_frames => '');
+ $self->set_result( 'no' );
}
-
- $self->set_result($can_build_call_frames?'yes':'no');
return 1;
}
-sub _call_frames_buildable {
- my $conf = shift;
- my $osname = $conf->data->get('osname');
- my $cpuarch = $conf->data->get('cpuarch');
- my $nvsize = $conf->data->get('nvsize');
- my $can_build_call_frames;
-
- if (defined $conf->options->get('buildframes')) {
- $can_build_call_frames = $conf->options->get('buildframes');
- }
- else {
- $can_build_call_frames = ($nvsize == 8 && $cpuarch eq 'i386'
- && $osname ne 'darwin');
- }
- return $can_build_call_frames;
-}
-
1;
# Local Variables:
View
@@ -5,15 +5,14 @@
use strict;
use warnings;
-use Test::More tests => 17;
+use Test::More tests => 23;
use lib qw( lib t/configure/testlib );
use_ok('config::init::defaults');
use_ok('config::auto::frames');
use Parrot::Configure;
use Parrot::Configure::Options qw( process_options );
use Parrot::Configure::Test qw(
test_step_thru_runstep
- rerun_defaults_for_testing
test_step_constructor_and_description
);
@@ -45,12 +44,13 @@ my $ret = $step->runstep($conf);
ok( $ret, "runstep() returned true value" );
ok( defined ( $step->result() ),
"Got defined result" );
+is( $step->result(), 'yes', "Result is 'yes', as expected" );
$conf->cc_clean();
-
+$step->set_result( undef );
$conf->replenish($serialized);
-##### _call_frames_buildable() #####
+###### _call_frames_buildable() #####
my $can_build_call_frames;
@@ -93,6 +93,29 @@ $can_build_call_frames = auto::frames::_call_frames_buildable($conf);
ok( ! $can_build_call_frames,
"_call_frames_buildable() returned false value, as expected (i386/linux/4)" );
+##### _handle_call_frames_buildable() #####
+
+$conf->data->set( nvsize => 8 );
+$conf->data->set( cpuarch => 'i386' );
+$conf->data->set( osname => 'linux' );
+
+my $rv;
+
+$can_build_call_frames = 0;
+
+$rv = $step->_handle_can_build_call_frames( $conf, $can_build_call_frames );
+ok( $rv, "_handle_can_build_call_frames() returned true value" );
+ok( ! $conf->data->get( 'cc_build_call_frames'),
+ "cc_build_call_frames not set to true, as expected" );
+ok( ! defined( $conf->data->get( 'has_exec_protect' ) ),
+ "has_exec_protect undefined, as expected" );
+is( $step->result(), 'no', "Result is 'no', as expected" );
+
+$conf->data->set( 'cc_build_call_frames' => undef );
+$conf->data->set( 'has_exec_protect' => undef );
+
+pass("Completed all tests in $0");
+
################### DOCUMENTATION ###################
=head1 NAME

0 comments on commit 9330765

Please sign in to comment.