fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / t / steps / auto / gcc-01.t
blobf3f8204e76fcd691d8536b6ec05517fe3660ce5f
1 #! perl
2 # Copyright (C) 2007, Parrot Foundation.
3 # $Id$
4 # auto/gcc-01.t
6 use strict;
7 use warnings;
8 use Test::More tests =>  79;
9 use Carp;
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( {
22     argv            => [],
23     mode            => q{configure},
24 } );
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);
46 my $gnucref = {};
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);
59 $gnucref = {};
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} ],
74     mode            => q{configure},
75 } );
76 $conf->add_steps($pkg);
77 $conf->options->set(%{$args});
78 $step = test_step_constructor_and_description($conf);
80     my $rv;
81     my $stdout;
82     my $gnucref = {};
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( {
97     argv            => [],
98     mode            => q{configure},
99 } );
100 $conf->add_steps($pkg);
101 $conf->options->set(%{$args});
102 $step = test_step_constructor_and_description($conf);
103 $gnucref = {};
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},
119 } );
120 $conf->add_steps($pkg);
121 $conf->options->set(%{$args});
122 $step = test_step_constructor_and_description($conf);
124     my $rv;
125     my $stdout;
126     my $gnucref = {};
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);
144     my $rv;
145     my $stdout;
146     my $gnucref = {};
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( {
164     argv            => [],
165     mode            => q{configure},
166 } );
167 $conf->add_steps($pkg);
168 $conf->options->set(%{$args});
169 $step = test_step_constructor_and_description($conf);
171     my $rv;
172     my $stdout;
173     my $gnucref = {};
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},
192 } );
193 $conf->add_steps($pkg);
194 $conf->options->set(%{$args});
195 $step = test_step_constructor_and_description($conf);
197     my $rv;
198     my $stdout;
199     my $gnucref = {};
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( {
217     argv            => [ ],
218     mode            => q{configure},
219 } );
220 $conf->add_steps($pkg);
221 $conf->options->set(%{$args});
222 $step = test_step_constructor_and_description($conf);
223 $gnucref = {};
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},
238 } );
239 $conf->add_steps($pkg);
240 $conf->options->set(%{$args});
241 $step = test_step_constructor_and_description($conf);
242 $gnucref = {};
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( {
257     argv            => [ ],
258     mode            => q{configure},
259 } );
260 $conf->add_steps($pkg);
261 $conf->options->set(%{$args});
262 $step = test_step_constructor_and_description($conf);
263 $gnucref = {};
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 ###################
281 =head1 NAME
283 auto/gcc-01.t - test auto::gcc
285 =head1 SYNOPSIS
287     % prove t/steps/auto/gcc-01.t
289 =head1 DESCRIPTION
291 The files in this directory test functionality used by F<Configure.pl>.
293 The tests in this file test auto::gcc.
295 =head1 AUTHOR
297 James E Keenan
299 =head1 SEE ALSO
301 config::auto::gcc, F<Configure.pl>.
303 =cut
305 # Local Variables:
306 #   mode: cperl
307 #   cperl-indent-level: 4
308 #   fill-column: 100
309 # End:
310 # vim: expandtab shiftwidth=4: