2 # Copyright (C) 2007, Parrot Foundation.
9 use Test::More tests => 15;
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 |;
17 is( $|, 1, "output autoflush is set" );
19 my ($args, $step_list_ref) = process_options(
21 argv => [q{--verbose-step=init::beta}],
25 ok( defined $args, "process_options returned successfully" );
28 my $conf = Parrot::Configure->new;
29 ok( defined $conf, "Parrot::Configure->new() returned okay" );
30 my $serialized = $conf->pcfreeze();
32 my $step = q{init::beta};
33 my $description = 'Determining if your computer does beta';
35 $conf->add_steps($step);
36 my @confsteps = @{ $conf->steps };
37 isnt( scalar @confsteps, 0,
38 "Parrot::Configure object 'steps' key holds non-empty array reference" );
39 is( scalar @confsteps, 1, "Parrot::Configure object 'steps' key holds ref to 1-element array" );
41 foreach my $k (@confsteps) {
42 $nontaskcount++ unless $k->isa("Parrot::Configure::Task");
44 is( $nontaskcount, 0, "Each step is a Parrot::Configure::Task object" );
45 is( $confsteps[0]->step, $step, "'step' element of Parrot::Configure::Task struct identified" );
46 ok( !ref( $confsteps[0]->object ),
47 "'object' element of Parrot::Configure::Task struct is not yet a ref" );
49 $conf->options->set(%args);
50 is( $conf->options->{c}->{debugging},
51 1, "command-line option '--debugging' has been stored in object" );
56 capture ( sub {$rv = $conf->runsteps}, \$stdout );
57 ok( $rv, "runsteps successfully ran $step" );
60 qr/$description\.\.\..*beta\sis\sverbose/s,
61 "Got message expected upon running $step"
65 $conf->replenish($serialized);
67 ##### designate multiple steps as --verbose-step; one of them bad #####
69 ($args, $step_list_ref) = process_options(
71 argv => [q{--verbose-step=alpha::beta,init::manifest}],
76 $conf->add_steps( @{ $step_list_ref } );
77 $conf->options->set(%args);
78 eval { $conf->runsteps(); };
80 qr/Argument to verbose-step option must be comma-delimited.*?steps/,
81 "Got expected error message for bad value to --verbose-step"
84 $conf->replenish($serialized);
86 ##### designate one step as --verbose-step; valid step #####
88 ($args, $step_list_ref) = process_options(
90 argv => [q{--verbose-step=init::mu}],
96 $conf->add_steps( $step );
97 $conf->options->set(%args);
100 my ($stdout, $stderr);
101 capture ( sub {$rv = $conf->runsteps}, \$stdout, \$stderr );
102 ok( $rv, "runsteps successfully ran $step" );
103 like($stdout, qr/^\s*init::mu.*done\.\s*$/s,
104 "As expected, description is only standard output");
107 pass("Completed all tests in $0");
109 ################### DOCUMENTATION ###################
113 043-verbose_step.t - test --verbose-step option to Configure.pl
117 % prove t/configure/043-verbose_step.t
121 The files in this directory test functionality used by F<Configure.pl>.
123 The tests in this file examine various cases involving the C<--verbose-step>
124 option to Configure.pl
132 Parrot::Configure, F<Configure.pl>.
138 # cperl-indent-level: 4
141 # vim: expandtab shiftwidth=4: