2 # Copyright (C) 2007, Parrot Foundation.
8 use Test::More tests => 79;
10 use lib qw( lib t/configure/testlib );
11 use_ok('config::auto::gcc');
12 use Parrot::Configure::Options qw( process_options );
13 use Parrot::Configure::Step::Test;
14 use Parrot::Configure::Test qw(
15 test_step_constructor_and_description
17 use IO::CaptureOutput qw | capture |;
19 ########## regular ##########
21 my ($args, $step_list_ref) = process_options( {
26 my $conf = Parrot::Configure::Step::Test->new;
27 $conf->include_config_results( $args );
29 my $serialized = $conf->pcfreeze();
31 my $pkg = q{auto::gcc};
33 $conf->add_steps($pkg);
34 $conf->options->set(%{$args});
35 my $step = test_step_constructor_and_description($conf);
37 ok($step->runstep($conf), "runstep returned true value");
39 $conf->replenish($serialized);
41 ########## _evaluate_gcc() ##########
43 $conf->add_steps($pkg);
44 $conf->options->set(%{$args});
45 $step = test_step_constructor_and_description($conf);
47 ok($step->_evaluate_gcc($conf, $gnucref),
48 "_evaluate_gcc() returned true value");
49 ok(! defined $conf->data->get( 'gccversion' ),
50 "gccversion undef as expected");
52 $conf->replenish($serialized);
54 ########## _evaluate_gcc() ##########
56 $conf->add_steps($pkg);
57 $conf->options->set(%{$args});
58 $step = test_step_constructor_and_description($conf);
60 $gnucref->{__GNUC__} = 1;
61 $gnucref->{__INTEL_COMPILER} = 1;
62 ok($step->_evaluate_gcc($conf, $gnucref),
63 "_evaluate_gcc() returned true value");
64 ok(! defined $conf->data->get( 'gccversion' ),
65 "gccversion undef as expected");
66 is($step->result(), q{no}, "Got expected result");
68 $conf->replenish($serialized);
70 ########## _evaluate_gcc(); --verbose ##########
72 ($args, $step_list_ref) = process_options( {
73 argv => [ q{--verbose} ],
76 $conf->add_steps($pkg);
77 $conf->options->set(%{$args});
78 $step = test_step_constructor_and_description($conf);
83 $gnucref->{__GNUC__} = undef;
84 capture ( sub {$rv = $step->_evaluate_gcc($conf, $gnucref) }, \$stdout);
85 ok($rv, "_evaluate_gcc() returned true value");
86 ok( $stdout, "verbose output captured" );
87 ok(! defined $conf->data->get( 'gccversion' ),
88 "gccversion undef as expected");
89 is($step->result(), q{no}, "Got expected result");
92 $conf->replenish($serialized);
94 ########## _evaluate_gcc() ##########
96 ($args, $step_list_ref) = process_options( {
100 $conf->add_steps($pkg);
101 $conf->options->set(%{$args});
102 $step = test_step_constructor_and_description($conf);
104 $gnucref->{__GNUC__} = 1;
105 $gnucref->{__INTEL_COMPILER} = 1;
106 ok($step->_evaluate_gcc($conf, $gnucref),
107 "_evaluate_gcc() returned true value");
108 ok(! defined $conf->data->get( 'gccversion' ),
109 "gccversion undef as expected");
110 is($step->result(), q{no}, "Got expected result");
112 $conf->replenish($serialized);
114 ########## _evaluate_gcc(); --verbose ##########
116 ($args, $step_list_ref) = process_options( {
117 argv => [ q{--verbose} ],
118 mode => q{configure},
120 $conf->add_steps($pkg);
121 $conf->options->set(%{$args});
122 $step = test_step_constructor_and_description($conf);
127 $gnucref->{__GNUC__} = q{abc123};
128 capture ( sub {$rv = $step->_evaluate_gcc($conf, $gnucref) }, \$stdout);
129 ok($rv, "_evaluate_gcc() returned true value");
130 ok( $stdout, "verbose output captured" );
131 ok(! defined $conf->data->get( 'gccversion' ),
132 "gccversion undef as expected");
133 is($step->result(), q{no}, "Got expected result");
136 $conf->replenish($serialized);
138 ########## _evaluate_gcc() ##########
140 $conf->add_steps($pkg);
141 $conf->options->set(%{$args});
142 $step = test_step_constructor_and_description($conf);
147 $gnucref->{__GNUC__} = q{123};
148 $gnucref->{__GNUC_MINOR__} = q{abc};
149 capture ( sub {$rv = $step->_evaluate_gcc($conf, $gnucref) }, \$stdout);
150 ok($rv, "_evaluate_gcc() returned true value");
151 ok( !$stdout, "verbose output captured" );
152 ok(defined $conf->data->get( 'gccversion' ),
153 "gccversion defined as expected");
154 is($conf->data->get( 'gccversion' ), 123,
155 "Got expected value for gccversion");
156 like($step->result(), qr/^yes/, "Got expected result");
159 $conf->replenish($serialized);
161 ########## _evaluate_gcc() ##########
163 ($args, $step_list_ref) = process_options( {
165 mode => q{configure},
167 $conf->add_steps($pkg);
168 $conf->options->set(%{$args});
169 $step = test_step_constructor_and_description($conf);
174 $gnucref->{__GNUC__} = q{123};
175 $gnucref->{__GNUC_MINOR__} = q{456};
176 capture ( sub {$rv = $step->_evaluate_gcc($conf, $gnucref) }, \$stdout);
177 ok($rv, "_evaluate_gcc() returned true value");
178 ok(defined $conf->data->get( 'gccversion' ),
179 "gccversion defined as expected");
180 is($conf->data->get( 'gccversion' ), q{123.456},
181 "Got expected value for gccversion");
182 like($step->result(), qr/^yes/, "Got expected result");
185 $conf->replenish($serialized);
187 ########## _evaluate_gcc(); --verbose ##########
189 ($args, $step_list_ref) = process_options( {
190 argv => [ q{--verbose} ],
191 mode => q{configure},
193 $conf->add_steps($pkg);
194 $conf->options->set(%{$args});
195 $step = test_step_constructor_and_description($conf);
200 $gnucref->{__GNUC__} = q{123};
201 $gnucref->{__GNUC_MINOR__} = q{456};
202 capture ( sub {$rv = $step->_evaluate_gcc($conf, $gnucref) }, \$stdout);
203 ok($rv, "_evaluate_gcc() returned true value");
204 ok( !$stdout, "verbose output captured" );
205 ok(defined $conf->data->get( 'gccversion' ),
206 "gccversion defined as expected");
207 is($conf->data->get( 'gccversion' ), q{123.456},
208 "Got expected value for gccversion");
209 like($step->result(), qr/^yes/, "Got expected result");
212 $conf->replenish($serialized);
214 ########## _evaluate_gcc() ##########
216 ($args, $step_list_ref) = process_options( {
218 mode => q{configure},
220 $conf->add_steps($pkg);
221 $conf->options->set(%{$args});
222 $step = test_step_constructor_and_description($conf);
224 $gnucref->{__GNUC__} = q{abc123};
225 ok($step->_evaluate_gcc($conf, $gnucref),
226 "_evaluate_gcc() returned true value");
227 ok(! defined $conf->data->get( 'gccversion' ),
228 "gccversion undef as expected");
229 is($step->result(), q{no}, "Got expected result");
231 $conf->replenish($serialized);
233 ########## _evaluate_gcc(); maintaiiner; cage ##########
235 ($args, $step_list_ref) = process_options( {
236 argv => [ q{--maintainer}, q{--cage} ],
237 mode => q{configure},
239 $conf->add_steps($pkg);
240 $conf->options->set(%{$args});
241 $step = test_step_constructor_and_description($conf);
243 $gnucref->{__GNUC__} = q{3};
244 $gnucref->{__GNUC_MINOR__} = q{1};
245 $conf->data->set( ccwarn => q{-Wfoobar -Wnofoobaz} );
246 ok($step->_evaluate_gcc($conf, $gnucref),
247 "_evaluate_gcc() returned true value");
248 ok(defined $conf->data->get( 'gccversion' ),
249 "gccversion defined as expected");
250 like($step->result(), qr/^yes/, "Got expected result");
252 $conf->replenish($serialized);
254 ########## _evaluate_gcc() ##########
256 ($args, $step_list_ref) = process_options( {
258 mode => q{configure},
260 $conf->add_steps($pkg);
261 $conf->options->set(%{$args});
262 $step = test_step_constructor_and_description($conf);
264 $gnucref->{__GNUC__} = q{3};
265 $gnucref->{__GNUC_MINOR__} = q{1};
267 $conf->data->set( OSNAME_provisional => 'hpux' );
268 ok($step->_evaluate_gcc($conf, $gnucref),
269 "_evaluate_gcc() returned true value");
270 ok(defined $conf->data->get( 'gccversion' ),
271 "gccversion defined as expected");
272 is($conf->data->get( 'gccversion' ), q{3.1},
273 "Got expected value for gccversion");
274 like($step->result(), qr/^yes/, "Got expected result");
277 pass("Completed all tests in $0");
279 ################### DOCUMENTATION ###################
283 auto/gcc-01.t - test auto::gcc
287 % prove t/steps/auto/gcc-01.t
291 The files in this directory test functionality used by F<Configure.pl>.
293 The tests in this file test auto::gcc.
301 config::auto::gcc, F<Configure.pl>.
307 # cperl-indent-level: 4
310 # vim: expandtab shiftwidth=4: