2 # Copyright (C) 2007, Parrot Foundation.
9 use Test::More tests => 29;
12 use Parrot::Configure;
13 use Parrot::Configure::Options qw( process_options );
14 use Parrot::Configure::Step::List qw| get_steps_list |;
17 is( $|, 1, "output autoflush is set" );
19 my $CC = "/usr/bin/gcc-3.3";
20 my $localargv = [ qq{--cc=$CC}, ];
21 my ($args, $step_list_ref) = process_options(
27 ok( defined $args, "process_options returned successfully" );
30 my $conf = Parrot::Configure->new;
31 ok( defined $conf, "Parrot::Configure->new() returned okay" );
32 isa_ok( $conf, "Parrot::Configure" );
34 my $newconf = Parrot::Configure->new;
35 ok( defined $newconf, "Parrot::Configure->new() returned okay" );
36 isa_ok( $newconf, "Parrot::Configure" );
37 is( $conf, $newconf, "Parrot::Configure object is a singleton" );
39 # Since these tests peek into the Parrot::Configure object, they will break if
40 # the structure of that object changes. We retain them for now to delineate
41 # our progress in testing the object.
42 foreach my $k (qw| steps options data |) {
43 ok( defined $conf->$k, "Parrot::Configure object has $k key" );
45 is( ref( $conf->steps ), q{ARRAY}, "Parrot::Configure object 'steps' key is array reference" );
46 is( scalar @{ $conf->steps },
47 0, "Parrot::Configure object 'steps' key holds empty array reference" );
48 foreach my $k (qw| options data |) {
49 isa_ok( $conf->$k, "Parrot::Configure::Data" );
52 can_ok( "Parrot::Configure", qw| data | );
53 can_ok( "Parrot::Configure", qw| options | );
54 can_ok( "Parrot::Configure", qw| steps | );
55 can_ok( "Parrot::Configure", qw| add_step | );
56 can_ok( "Parrot::Configure", qw| add_steps | );
57 can_ok( "Parrot::Configure", qw| run_single_step | );
58 can_ok( "Parrot::Configure", qw| runsteps | );
59 can_ok( "Parrot::Configure", qw| _run_this_step | );
61 $conf->add_steps( get_steps_list() );
62 my @confsteps = @{ $conf->steps };
63 isnt( scalar @confsteps, 0,
64 "Parrot::Configure object 'steps' key holds non-empty array reference" );
66 foreach my $k (@confsteps) {
67 $nontaskcount++ unless $k->isa("Parrot::Configure::Task");
69 is( $nontaskcount, 0, "Each step is a Parrot::Configure::Task object" );
71 $conf->options->set(%args);
72 is( $conf->options->{c}->{cc}, $CC, "command-line option '--cc' has been stored in object" );
73 is( $conf->options->{c}->{debugging},
74 1, "command-line option '--debugging' has been stored in object" );
76 my $res = eval "no strict; use Parrot::Config::Generated; \\%PConfig";
78 my $reason = <<REASON;
79 If you have already completed configuration,
80 you can call Parrot::Configure::Data::get_PConfig().
81 But here you are testing for that method's failure.
84 skip $reason, 1 if defined $res;
86 eval { $conf->data()->get_PConfig(); };
89 qr/You cannot use --step until you have completed the full configure process/,
90 "Got expected error message for --step option and get_PConfig() without prior configuration"
94 $res = eval "no strict; use Parrot::Config::Generated; \\%PConfig_Temp";
96 my $reason = <<REASON;
97 If you have already completed configuration,
98 you can call Parrot::Configure::Data::get_PConfig_Temp().
99 But here you are testing for that method's failure.
102 skip $reason, 1 if defined $res;
104 eval { $conf->data()->get_PConfig_Temp(); };
107 qr/You cannot use --step until you have completed the full configure process/,
108 "Got expected error message for --step option and get_PConfig_Temp() without prior configuration"
112 pass("Completed all tests in $0");
114 ################### DOCUMENTATION ###################
118 004-configure.t - test Parrot::Configure
122 % prove t/configure/004-configure.t
126 The files in this directory test functionality used by F<Configure.pl>.
128 The tests in this file test those Parrot::Configure methods regularly called
129 by F<Configure.pl> up to, but not including, C<Parrot::Configure::runsteps()>.
130 There is also a test for failure of the C<--step> option without prior
131 completed configuration.
139 Parrot::Configure, F<Configure.pl>.
145 # cperl-indent-level: 4
148 # vim: expandtab shiftwidth=4: