Skip to content
Newer
Older
100644 98 lines (73 sloc) 2.51 KB
25830bb @jkeenan Applying patch submitted in
jkeenan authored
1 #! perl
781dbba @rurban [build] turn off --debugging by default, accept --debugging arg
rurban authored
2 # Copyright (C) 2007,2014, Parrot Foundation.
0a8cada @jkeenan Change names of all t/configure/*.t files beginning with double digit…
jkeenan authored
3 # 016-no_return_but_result.t
25830bb @jkeenan Applying patch submitted in
jkeenan authored
4
5 use strict;
6 use warnings;
7
781dbba @rurban [build] turn off --debugging by default, accept --debugging arg
rurban authored
8 use Test::More tests => 12;
25830bb @jkeenan Applying patch submitted in
jkeenan authored
9 use Carp;
950e648 @jkeenan Additional correction of errors in @INC in test files diagnosed by Andy
jkeenan authored
10 use lib qw( lib t/configure/testlib );
25830bb @jkeenan Applying patch submitted in
jkeenan authored
11 use Parrot::Configure;
12 use Parrot::Configure::Options qw( process_options );
bd6f37d @rurban [GH #892] Fixup IO::CaptureOutput removal
rurban authored
13 use Parrot::Configure::Utils qw | capture |;
25830bb @jkeenan Applying patch submitted in
jkeenan authored
14
15 $| = 1;
22267a6 @paultcochrane [t] Tidied code with perltidy
paultcochrane authored
16 is( $|, 1, "output autoflush is set" );
17
780cbd7 @jkeenan Merge newsc branch into trunk, implementing Configuration-File interf…
jkeenan authored
18 my ($args, $step_list_ref) = process_options(
22267a6 @paultcochrane [t] Tidied code with perltidy
paultcochrane authored
19 {
20 argv => [],
21 mode => q{configure},
22 }
23 );
24 ok( defined $args, "process_options returned successfully" );
25830bb @jkeenan Applying patch submitted in
jkeenan authored
25 my %args = %$args;
26
27 my $conf = Parrot::Configure->new;
22267a6 @paultcochrane [t] Tidied code with perltidy
paultcochrane authored
28 ok( defined $conf, "Parrot::Configure->new() returned okay" );
25830bb @jkeenan Applying patch submitted in
jkeenan authored
29
22267a6 @paultcochrane [t] Tidied code with perltidy
paultcochrane authored
30 my $step = q{init::zeta};
6b93a7c @jkeenan Applying patch submitted in
jkeenan authored
31 my $description = 'Determining if your computer does zeta';
25830bb @jkeenan Applying patch submitted in
jkeenan authored
32
22267a6 @paultcochrane [t] Tidied code with perltidy
paultcochrane authored
33 $conf->add_steps($step);
34 my @confsteps = @{ $conf->steps };
35 isnt( scalar @confsteps, 0,
36 "Parrot::Configure object 'steps' key holds non-empty array reference" );
37 is( scalar @confsteps, 1, "Parrot::Configure object 'steps' key holds ref to 1-element array" );
25830bb @jkeenan Applying patch submitted in
jkeenan authored
38 my $nontaskcount = 0;
39 foreach my $k (@confsteps) {
40 $nontaskcount++ unless $k->isa("Parrot::Configure::Task");
41 }
22267a6 @paultcochrane [t] Tidied code with perltidy
paultcochrane authored
42 is( $nontaskcount, 0, "Each step is a Parrot::Configure::Task object" );
43 is( $confsteps[0]->step, $step, "'step' element of Parrot::Configure::Task struct identified" );
44 ok( !ref( $confsteps[0]->object ),
45 "'object' element of Parrot::Configure::Task struct is not yet a ref" );
25830bb @jkeenan Applying patch submitted in
jkeenan authored
46
47 $conf->options->set(%args);
48
6b93a7c @jkeenan Applying patch submitted in
jkeenan authored
49 {
f834dc1 @jkeenan Merge capture branch into trunk. With this we replace usage of Parrot…
jkeenan authored
50 my $rv;
51 my ($stdout, $stderr);
52 capture ( sub {$rv = $conf->runsteps}, \$stdout, \$stderr );
53 ok( $rv, "runsteps successfully ran $step" );
54 like( $stdout, qr/$description/s, "Got correct description for $step" );
55 like(
56 $stderr,
6b93a7c @jkeenan Applying patch submitted in
jkeenan authored
57 qr/step $step failed:\sGoodbye, cruel world/,
f834dc1 @jkeenan Merge capture branch into trunk. With this we replace usage of Parrot…
jkeenan authored
58 "Got error message expected upon running $step");
59 }
25830bb @jkeenan Applying patch submitted in
jkeenan authored
60
61 pass("Completed all tests in $0");
62
63 ################### DOCUMENTATION ###################
64
65 =head1 NAME
66
0a8cada @jkeenan Change names of all t/configure/*.t files beginning with double digit…
jkeenan authored
67 016-no_return_but_result.t - see what happens when configuration step returns
6b93a7c @jkeenan Applying patch submitted in
jkeenan authored
68 undefined value but has a defined result method
25830bb @jkeenan Applying patch submitted in
jkeenan authored
69
70 =head1 SYNOPSIS
71
0a8cada @jkeenan Change names of all t/configure/*.t files beginning with double digit…
jkeenan authored
72 % prove t/configure/016-no_return_but_result.t
25830bb @jkeenan Applying patch submitted in
jkeenan authored
73
74 =head1 DESCRIPTION
75
76 The files in this directory test functionality used by F<Configure.pl>.
77
78 The tests in this file examine what happens when your configuration step
79 module returns something other than the object but has some other defined
80 result method.
81
82 =head1 AUTHOR
83
84 James E Keenan
85
86 =head1 SEE ALSO
87
88 Parrot::Configure, F<Configure.pl>.
89
90 =cut
91
92 # Local Variables:
93 # mode: cperl
94 # cperl-indent-level: 4
95 # fill-column: 100
96 # End:
97 # vim: expandtab shiftwidth=4:
Something went wrong with that request. Please try again.