1#! perl 2# Copyright (C) 2007,2014, Parrot Foundation. 3# 013-die.t 4 5use strict; 6use warnings; 7 8use Test::More tests => 11; 9use Carp; 10use lib qw( lib t/configure/testlib ); 11use Parrot::Configure; 12use Parrot::Configure::Options qw( process_options ); 13use Parrot::Configure::Utils qw | capture |; 14 15$| = 1; 16is( $|, 1, "output autoflush is set" ); 17 18my ($args, $step_list_ref) = process_options( 19 { 20 argv => [], 21 mode => q{configure}, 22 } 23); 24ok( defined $args, "process_options returned successfully" ); 25my %args = %$args; 26 27my $conf = Parrot::Configure->new; 28ok( defined $conf, "Parrot::Configure->new() returned okay" ); 29 30my $step = q{init::gamma}; 31my $description = 'Determining if your computer does gamma'; 32 33$conf->add_steps($step); 34my @confsteps = @{ $conf->steps }; 35isnt( scalar @confsteps, 0, 36 "Parrot::Configure object 'steps' key holds non-empty array reference" ); 37is( scalar @confsteps, 1, "Parrot::Configure object 'steps' key holds ref to 1-element array" ); 38my $nontaskcount = 0; 39foreach my $k (@confsteps) { 40 $nontaskcount++ unless $k->isa("Parrot::Configure::Task"); 41} 42is( $nontaskcount, 0, "Each step is a Parrot::Configure::Task object" ); 43is( $confsteps[0]->step, $step, "'step' element of Parrot::Configure::Task struct identified" ); 44ok( !ref( $confsteps[0]->object ), 45 "'object' element of Parrot::Configure::Task struct is not yet a ref" ); 46 47$conf->options->set(%args); 48 49my $errstr; 50{ 51 my $rv; 52 my ($stdout, $stderr); 53 capture ( sub {eval {$rv = $conf->runsteps } }, \$stdout, \$stderr ); 54 like( 55 $stdout, 56 qr/$description/s, 57 "Got message expected upon running $step" 58 ); 59 like( 60 $stderr, 61 qr/step $step died during execution: Dying gamma just to see what happens/, 62 "Got expected error message" 63 ); 64} 65 66pass("Completed all tests in $0"); 67 68################### DOCUMENTATION ################### 69 70=head1 NAME 71 72013-die.t - test what happens when a configuration step dies during execution 73 74=head1 SYNOPSIS 75 76 % prove t/configure/013-die.t 77 78=head1 DESCRIPTION 79 80The files in this directory test functionality used by F<Configure.pl>. 81 82The tests in this file examine what happens when your configuration step dies 83during execution. 84 85=head1 AUTHOR 86 87James E Keenan 88 89=head1 SEE ALSO 90 91Parrot::Configure, F<Configure.pl>. 92 93=cut 94 95# Local Variables: 96# mode: cperl 97# cperl-indent-level: 4 98# fill-column: 100 99# End: 100# vim: expandtab shiftwidth=4: 101