1#! perl 2# Copyright (C) 2007,2014, Parrot Foundation. 3# 006-bad_step.t 4 5use strict; 6use warnings; 7 8use Test::More tests => 10; 9use Carp; 10use lib qw( lib ); 11use Parrot::Configure; 12use Parrot::Configure::Options qw( process_options ); 13 14$| = 1; 15is( $|, 1, "output autoflush is set" ); 16 17my ($args, $step_list_ref) = process_options( 18 { 19 argv => [], 20 mode => q{configure}, 21 } 22); 23ok( defined $args, "process_options returned successfully" ); 24my %args = %$args; 25 26my $conf = Parrot::Configure->new; 27ok( defined $conf, "Parrot::Configure->new() returned okay" ); 28 29my $badstep = q{bad::step}; 30my $badsteppath = q{bad/step.pm}; 31 32$conf->add_steps($badstep); 33my @confsteps = @{ $conf->steps }; 34isnt( scalar @confsteps, 0, 35 "Parrot::Configure object 'steps' key holds non-empty array reference" ); 36is( scalar @confsteps, 1, "Parrot::Configure object 'steps' key holds ref to 1-element array" ); 37my $nontaskcount = 0; 38foreach my $k (@confsteps) { 39 $nontaskcount++ unless $k->isa("Parrot::Configure::Task"); 40} 41is( $nontaskcount, 0, "Each step is a Parrot::Configure::Task object" ); 42is( $confsteps[0]->step, $badstep, "'step' element of Parrot::Configure::Task struct identified" ); 43ok( !ref( $confsteps[0]->object ), 44 "'object' element of Parrot::Configure::Task struct is not yet a ref" ); 45 46$conf->options->set(%args); 47 48my $rv; 49eval { $rv = $conf->runsteps; }; 50like( 51 $@, qr/Can't locate $badsteppath in \@INC/, #' 52 "Got expected die message when runsteps() called with nonexistent step" 53); 54 55pass("Completed all tests in $0"); 56 57################### DOCUMENTATION ################### 58 59=head1 NAME 60 61006-bad_step.t - test bad step failure case in Parrot::Configure 62 63=head1 SYNOPSIS 64 65 % prove t/configure/006-bad_step.t 66 67=head1 DESCRIPTION 68 69The files in this directory test functionality used by F<Configure.pl>. 70 71The tests in this file examine what happens when you attempt to do a 72C<runsteps> on a non-existent step. 73 74=head1 AUTHOR 75 76James E Keenan 77 78=head1 SEE ALSO 79 80Parrot::Configure, F<Configure.pl>. 81 82=cut 83 84# Local Variables: 85# mode: cperl 86# cperl-indent-level: 4 87# fill-column: 100 88# End: 89# vim: expandtab shiftwidth=4: 90