Author: jkeenan Date: Fri Feb 15 16:28:50 2008 New Revision: 25748 Modified: branches/tcif/lib/Parrot/Configure/Parallel/Trace.pm branches/tcif/t/configure/061-parallel.t
Log: First tests for Parrot::Configure::Parallel::Trace methods, plus a little refactoring in module. Modified: branches/tcif/lib/Parrot/Configure/Parallel/Trace.pm ============================================================================== --- branches/tcif/lib/Parrot/Configure/Parallel/Trace.pm (original) +++ branches/tcif/lib/Parrot/Configure/Parallel/Trace.pm Fri Feb 15 16:28:50 2008 @@ -8,6 +8,8 @@ =head1 SYNOPSIS + use Parrot::Configure::Parallel::Trace; + $trace = Parrot::Configure::Parallel::Trace->new('current_test_script'); @@ -15,20 +17,20 @@ $step_position = $trace->get_step_position(); - $stepsref = $trace->get_all_step_positions() + $stepsref = $trace->get_all_step_positions(); $state = $trace->retrieve_state(); $trace->dump_state(); - $trace->get_previous_state($step_name); + $trace->get_previous_state(); $trace->update_state( { state => $state, conf => $conf, } ); - $trace->store_this_step_pure($step_name); + $trace->store_this_step_pure(); Used only in configuration step tests found in F<t/steps/>. @@ -42,7 +44,7 @@ use File::Basename; use Storable qw( nstore retrieve ); use lib qw( lib ); -use Parrot::Configure::Step::List qw( get_steps_list ); +use Parrot::Configure::Step::List (); use Parrot::Configure::Parallel; use Parrot::Configure::Options qw( process_options ); @@ -103,7 +105,7 @@ my %args; $args{sto} = $sto; - my @steps_list = get_steps_list(); + my @steps_list = Parrot::Configure::Step::List::get_steps_list(); my %steps_position; for (my $i=0; $i<=$#steps_list; $i++) { $steps_position{$steps_list[$i]} = $i+1; Modified: branches/tcif/t/configure/061-parallel.t ============================================================================== --- branches/tcif/t/configure/061-parallel.t (original) +++ branches/tcif/t/configure/061-parallel.t Fri Feb 15 16:28:50 2008 @@ -1,60 +1,76 @@ #! perl -# Copyright (C) 2007, The Perl Foundation. +# Copyright (C) 2008, The Perl Foundation. # $Id$ -# 060-silent.t +# 061-parallel.t use strict; use warnings; -use Test::More tests => 11; +use Test::More qw(no_plan); # tests => 11; use Carp; -use lib qw( lib t/configure/testlib ); -use Parrot::Configure; -use Parrot::Configure::Options qw( process_options ); +use lib qw( lib ); +#use Parrot::Configure; +#use Parrot::Configure::Options qw( process_options ); use IO::CaptureOutput qw | capture |; +use Parrot::Configure::Parallel::Trace; +#use Data::Dumper; -$| = 1; -is( $|, 1, "output autoflush is set" ); - -my $args = process_options( - { - argv => [ q{--silent} ], - mode => q{configure}, - } +my $trace; +eval { $trace = Parrot::Configure::Parallel::Trace->new(); }; +like($@, qr/^Need to provide name of test script/, + "Constructor correctly failed due to lack of argument"); + [EMAIL PROTECTED]::Configure::Step::List::steps = qw( + init::alpha + init::beta + init::gamma ); -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::lambda}; -my $description = 'Determining if your computer does lambda'; +$trace = + Parrot::Configure::Parallel::Trace->new('t/pseudo/init_alpha-01.t'); +ok(defined $trace, "Constructor returned defined value"); + +is($trace->get_step_name(), 'init::alpha', + "Got expected step class name"); + +is($trace->get_step_position(), 1, + "Got expected step class position"); + +my $stepsref = $trace->get_all_step_positions(); +is($stepsref->{'init::alpha'}, 1, + "Got expected step class position"); +is($stepsref->{'init::beta'}, 2, + "Got expected step class position"); +is($stepsref->{'init::gamma'}, 3, + "Got expected step class position"); + +$Parrot::Configure::Parallel::Trace::sto = q{.nonexistent.sto}; +$trace = + Parrot::Configure::Parallel::Trace->new('t/pseudo/init_beta-01.t'); +ok(defined $trace, "New constructor returned defined value"); +my $stateref = $trace->retrieve_state(); +is(ref($stateref), 'ARRAY', + "retrieve_state() returned array ref"); +is(scalar( @{$stateref} ), 0, + "No Storable object means retrieve_state() returns ref to empty array"); + +#use Data::Dumper;$Data::Dumper::Indent=1; +#print STDERR Dumper $stateref; + +my ($stdout, $stderr); +capture( + sub { $trace->dump_state(); }, + \$stdout, +); +like($stdout, qr/^\$VAR1.*\[\]/, "Got expected Dumper output"); -$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" ); -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 ($stdout); - capture ( sub { eval { $rv = $conf->runsteps; } }, \$stdout); - ok(! $stdout, "silent option worked"); -} +#$trace->get_previous_state($step_name); +# +#$trace->update_state( { +# state => $state, +# conf => $conf, +#} ); +# +#$trace->store_this_step_pure($step_name); pass("Completed all tests in $0"); @@ -62,18 +78,18 @@ =head1 NAME -060-silent.t - test what happens when the C<--silent> option is set +061-parallel.t - Tests for Parrot::Configure::Parallel::Trace =head1 SYNOPSIS - % prove t/configure/060-silent.t + % prove t/configure/061-parallel.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 -succeeds but the C<--silent> option has been set. +The tests in this file examine what happens when you run +Parrot::Configure::Parallel::Trace. =head1 AUTHOR @@ -81,7 +97,8 @@ =head1 SEE ALSO -Parrot::Configure, F<Configure.pl>. +Parrot::Configure::Parallel, Parrot::Configure::Parallel::Trace, +F<Configure.pl>. =cut