tagged release 0.6.4
[parrot.git] / t / configure / 052-fatal_step.t
blobf92acbafe79ebb396bbbf457a6e02fcdcc01063a
1 #! perl
2 # Copyright (C) 2007, The Perl Foundation.
3 # $Id$
4 # 052-fatal_step.t
6 use strict;
7 use warnings;
9 use Test::More tests => 13;
10 use Carp;
11 use lib qw( lib t/configure/testlib );
12 use Parrot::Configure;
13 use Parrot::Configure::Options qw( process_options );
14 use IO::CaptureOutput qw | capture |;
16 $| = 1;
17 is( $|, 1, "output autoflush is set" );
19 my $args = process_options(
20     {
21         argv => [ q{--fatal-step=init::zeta,init::manifest} ],
22         mode => q{configure},
23     }
25 ok( defined $args, "process_options returned successfully" );
26 my %args = %$args;
28 my $conf = Parrot::Configure->new;
29 ok( defined $conf, "Parrot::Configure->new() returned okay" );
31 my $step        = q{init::zeta};
32 my $description = 'Determining if your computer does zeta';
34 $conf->add_steps($step);
35 my @confsteps = @{ $conf->steps };
36 isnt( scalar @confsteps, 0,
37     "Parrot::Configure object 'steps' key holds non-empty array reference" );
38 is( scalar @confsteps, 1, "Parrot::Configure object 'steps' key holds ref to 1-element array" );
39 my $nontaskcount = 0;
40 foreach my $k (@confsteps) {
41     $nontaskcount++ unless $k->isa("Parrot::Configure::Task");
43 is( $nontaskcount, 0, "Each step is a Parrot::Configure::Task object" );
44 is( $confsteps[0]->step, $step, "'step' element of Parrot::Configure::Task struct identified" );
45 ok( !ref( $confsteps[0]->object ),
46     "'object' element of Parrot::Configure::Task struct is not yet a ref" );
48 $conf->options->set(%args);
49 is( $conf->options->{c}->{debugging},
50     1, "command-line option '--debugging' has been stored in object" );
53     my $rv;
54     my ($stdout, $stderr);
55     capture ( sub {$rv    = $conf->runsteps}, \$stdout, \$stderr );
56     ok(! defined $rv, 'runsteps() returned undef');
58     like($stdout,
59     qr/$description\.\.\./s,
60     "Got STDOUT message expected upon running $step");
61     like($stderr,
62     qr/step $step failed:/s,
63     "Got STDERR message expected upon running $step");
66 pass("Completed all tests in $0");
68 ################### DOCUMENTATION ###################
70 =head1 NAME
72 052-fatal_step.t - test bad step failure case in Parrot::Configure
74 =head1 SYNOPSIS
76     % prove t/configure/052-fatal_step.t
78 =head1 DESCRIPTION
80 The files in this directory test functionality used by F<Configure.pl>.
82 The tests in this file examine what happens when you set the C<--fatal-step>
83 option for multiple configuration steps and one of those steps returns an
84 undefined value.
86 =head1 AUTHOR
88 James E Keenan
90 =head1 SEE ALSO
92 Parrot::Configure, F<Configure.pl>.
94 =cut
96 # Local Variables:
97 #   mode: cperl
98 #   cperl-indent-level: 4
99 #   fill-column: 100
100 # End:
101 # vim: expandtab shiftwidth=4: