|
|
Author: jkeenan
Date: Fri Dec 28 08:50:37 2007
New Revision: 24249
Added:
trunk/t/configure/132-auto_jit-02.t (contents, props changed)
Modified:
trunk/config/auto/jit.pm
Log:
auto::jit: Start to refactor the guts of runstep() to increase
testability. Create _handle_execcapable() and provide additional test
file.
Modified: trunk/config/auto/jit.pm
==============================================================================
--- trunk/config/auto/jit.pm (original)
+++ trunk/config/auto/jit.pm Fri Dec 28 08:50:37 2007
@@ -118,7 +118,6 @@
|| ( $jitcpuarch eq 'ppc' )
|| ( $jitcpuarch eq 'arm' ) )
{
-# if ( $jitcpuarch =~ /^(i386|ppc|arm)$/ ) {
$execcapable = 1;
unless ( ( $osname eq 'openbsd' )
|| ( $osname eq 'freebsd' )
@@ -132,22 +131,7 @@
}
$execcapable = $conf->options->get('execcapable')
if defined $conf->options->get('execcapable');
- if ($execcapable) {
- $conf->data->set(
- TEMP_exec_h =>
-'$(SRC_DIR)/jit.h $(INC_DIR)/exec.h $(SRC_DIR)/exec_dep.h
$(SRC_DIR)/exec_save.h',
- TEMP_exec_o =>
- '$(SRC_DIR)/exec$(O) $(SRC_DIR)/exec_cpu$(O)
$(SRC_DIR)/exec_save$(O)',
- execcapable => 1
- );
- }
- else {
- $conf->data->set(
- TEMP_exec_h => '',
- TEMP_exec_o => '',
- execcapable => 0
- );
- }
+ _handle_execcapable($conf, $execcapable);
# test for executable malloced memory
if ( -e "config/auto/jit/test_exec_$osname.in" ) {
@@ -199,6 +183,27 @@
return 1;
}
+sub _handle_execcapable {
+ my ($conf, $execcapable) = @_;
+ if ($execcapable) {
+ $conf->data->set(
+ TEMP_exec_h =>
+'$(SRC_DIR)/jit.h $(INC_DIR)/exec.h $(SRC_DIR)/exec_dep.h
$(SRC_DIR)/exec_save.h',
+ TEMP_exec_o =>
+ '$(SRC_DIR)/exec$(O) $(SRC_DIR)/exec_cpu$(O)
$(SRC_DIR)/exec_save$(O)',
+ execcapable => 1
+ );
+ }
+ else {
+ $conf->data->set(
+ TEMP_exec_h => '',
+ TEMP_exec_o => '',
+ execcapable => 0
+ );
+ }
+ return 1;
+}
+
1;
# Local Variables:
Added: trunk/t/configure/132-auto_jit-02.t
==============================================================================
--- (empty file)
+++ trunk/t/configure/132-auto_jit-02.t Fri Dec 28 08:50:37 2007
@@ -0,0 +1,90 @@
+#! perl
+# Copyright (C) 2007, The Perl Foundation.
+# $Id$
+# 132-auto_jit-02.t
+
+use strict;
+use warnings;
+use Test::More tests => 15;
+use Carp;
+use lib qw( lib t/configure/testlib );
+use_ok('config::init::defaults');
+use_ok('config::auto::jit');
+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::jit};
+
+$conf->add_steps($pkg);
+$conf->options->set( %{$args} );
+
+my ( $task, $step_name, $step);
+$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" );
+
+ok(auto::jit::_handle_execcapable($conf, 1),
+ "_handle_execcapable() returned true value");
+is($conf->data->get('execcapable'), 1,
+ "Got expected value for execcapable");
+# prepare for next test
+$conf->data->set('execcapable' => undef);
+
+ok(auto::jit::_handle_execcapable($conf, 0),
+ "_handle_execcapable() returned true value");
+is($conf->data->get('execcapable'), 0,
+ "Got expected value for execcapable");
+$conf->data->set('execcapable' => undef);
+
+pass("Keep Devel::Cover happy");
+pass("Completed all tests in $0");
+
+################### DOCUMENTATION ###################
+
+=head1 NAME
+
+132-auto_jit-02.t - test config::auto::jit
+
+=head1 SYNOPSIS
+
+ % prove t/configure/132-auto_jit-02.t
+
+=head1 DESCRIPTION
+
+The files in this directory test functionality used by F<Configure.pl>.
+
+The tests in this file tests config::auto::jit with the C<--miniparrot>
+option.
+
+=head1 AUTHOR
+
+James E Keenan
+
+=head1 SEE ALSO
+
+config::auto::jit, F<Configure.pl>.
+
+=cut
+
+# Local Variables:
+# mode: cperl
+# cperl-indent-level: 4
+# fill-column: 100
+# End:
+# vim: expandtab shiftwidth=4:
|
|