Author: jkeenan Date: Wed Sep 19 19:26:58 2007 New Revision: 21414 Added: branches/reconfigure/t/configure/040-return_undef.t (contents, props changed) branches/reconfigure/t/configure/testlib/init/eta.pm (contents, props changed) Modified: branches/reconfigure/MANIFEST branches/reconfigure/t/configure/016-no_return_but_result.t
Log: Add a test file for testing case in which configuration step returns an undefined value. Add module holding config step to assist in testing. Specify exact number of tests in plan. Modified: branches/reconfigure/MANIFEST ============================================================================== --- branches/reconfigure/MANIFEST (original) +++ branches/reconfigure/MANIFEST Wed Sep 19 19:26:58 2007 @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Wed Sep 19 00:39:01 2007 UT +# generated by tools/dev/mk_manifest_and_skip.pl Thu Sep 20 02:23:24 2007 UT # # See tools/dev/install_files.pl for documentation on the # format of this file. @@ -2925,6 +2925,7 @@ t/configure/037-run_single_step.t [] t/configure/038-run_single_step.t [] t/configure/039-slurp_file.t [] +t/configure/040-return_undef.t [] t/configure/101-init_manifest.01.t [] t/configure/101-init_manifest.02.t [] t/configure/102-init_defaults.01.t [] @@ -3009,6 +3010,7 @@ t/configure/testlib/init/beta.pm [] t/configure/testlib/init/delta.pm [] t/configure/testlib/init/epsilon.pm [] +t/configure/testlib/init/eta.pm [] t/configure/testlib/init/foobar.pm [] t/configure/testlib/init/gamma.pm [] t/configure/testlib/init/zeta.pm [] Modified: branches/reconfigure/t/configure/016-no_return_but_result.t ============================================================================== --- branches/reconfigure/t/configure/016-no_return_but_result.t (original) +++ branches/reconfigure/t/configure/016-no_return_but_result.t Wed Sep 19 19:26:58 2007 @@ -6,7 +6,7 @@ use strict; use warnings; -use Test::More qw(no_plan); # tests => 11; +use Test::More tests => 14; use Carp; use lib qw( lib t/configure/testlib ); use Parrot::Configure; Added: branches/reconfigure/t/configure/040-return_undef.t ============================================================================== --- (empty file) +++ branches/reconfigure/t/configure/040-return_undef.t Wed Sep 19 19:26:58 2007 @@ -0,0 +1,113 @@ +#! perl +# Copyright (C) 2007, The Perl Foundation. +# $Id$ +# 040-return_undef.t + +use strict; +use warnings; + +use Test::More tests => 14; +use Carp; +use lib qw( lib t/configure/testlib ); +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::IO::Capture::Mini; + +$| = 1; +is($|, 1, "output autoflush is set"); + +my $args = process_options( { + argv => [ ], + mode => q{configure}, +} ); +ok(defined $args, "process_options returned successfully"); +my %args = %$args; + +my $conf = Parrot::Configure->new; +ok(defined $conf, "Parrot::Configure->new() returned okay"); + +my $step = q{init::eta}; +my $description = 'Determining if your computer does eta'; + +$conf->add_steps( $step ); +my @confsteps = @{$conf->steps}; +isnt(scalar @confsteps, 0, + "Parrot::Configure object 'steps' key holds non-empty array reference"); +is(scalar @confsteps, 1, + "Parrot::Configure object 'steps' key holds ref to 1-element array"); +my $nontaskcount = 0; +foreach my $k (@confsteps) { + $nontaskcount++ unless $k->isa("Parrot::Configure::Task"); +} +is($nontaskcount, 0, "Each step is a Parrot::Configure::Task object"); +is($confsteps[0]->step, $step, + "'step' element of Parrot::Configure::Task struct identified"); +is(ref($confsteps[0]->params), 'ARRAY', + "'params' element of Parrot::Configure::Task struct is array ref"); +ok(! ref($confsteps[0]->object), + "'object' element of Parrot::Configure::Task struct is not yet a ref"); + +$conf->options->set(%args); +is($conf->options->{c}->{debugging}, 1, + "command-line option '--debugging' has been stored in object"); + +my $rv; +my ($tie, @lines, $errtie, @errlines); +{ + $tie = tie *STDOUT, "Parrot::IO::Capture::Mini" + or croak "Unable to tie"; + $errtie = tie *STDERR, "Parrot::IO::Capture::Mini" + or croak "Unable to tie"; + $rv = $conf->runsteps; + @lines = $tie->READLINE; + @errlines = $errtie->READLINE; +} +untie *STDOUT; +untie *STDERR; +ok($rv, "runsteps successfully ran $step"); +my $bigmsg = join q{}, @lines; +like($bigmsg, + qr/$description/s, + "Got correct description for $step"); +my $errmsg = join q{}, @errlines; +like($errmsg, + qr/step $step failed:/, + "Got error message expected upon running $step"); + +pass("Completed all tests in $0"); + +################### DOCUMENTATION ################### + +=head1 NAME + +040-return_undef.t - see what happens when configuration step returns an +undefined value + +=head1 SYNOPSIS + + % prove t/configure/040-return_undef.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F<Configure.pl>. + +The tests in this file examine what happens when your configuration step +module returns something other than the object but has some other defined +result method. + +=head1 AUTHOR + +James E Keenan + +=head1 SEE ALSO + +Parrot::Configure, F<Configure.pl>. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Added: branches/reconfigure/t/configure/testlib/init/eta.pm ============================================================================== --- (empty file) +++ branches/reconfigure/t/configure/testlib/init/eta.pm Wed Sep 19 19:26:58 2007 @@ -0,0 +1,38 @@ +# Copyright (C) 2001-2003, The Perl Foundation. +# $Id$ + +=head1 NAME + +t/configure/testlib/init/eta.pm - Module used in configuration tests + +=cut + +package init::eta; +use strict; +use warnings; +use vars qw($description @args); + +use base qw(Parrot::Configure::Step::Base); + +use Parrot::Configure::Step; + +$description = 'Determining if your computer does eta'; [EMAIL PROTECTED] = (); + +my $result = q|Hello world|; + +sub runstep { + my ( $self, $conf ) = @_; + $self->set_result( $result ); + return; +} + +1; + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: +