fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / t / steps / init / optimize-01.t
blob98e42edd26c38864162650e2a74126e7d407d9f1
1 #! perl
2 # Copyright (C) 2007, Parrot Foundation.
3 # $Id$
4 # init/optimize-01.t
5 use strict;
6 use warnings;
7 use Test::More tests => 28;
8 use Carp;
9 use lib qw( lib t/configure/testlib );
10 use_ok('config::init::optimize');
11 use Parrot::Configure::Options qw( process_options );
12 use Parrot::Configure::Step::Test;
13 use Parrot::Configure::Test qw(
14     test_step_constructor_and_description
16 use IO::CaptureOutput qw | capture |;
18 ########## no optimization (default) ##########
20 my ($args, $step_list_ref) = process_options( {
21     argv => [],
22     mode => q{configure},
23 } );
25 my $conf = Parrot::Configure::Step::Test->new;
26 $conf->include_config_results( $args );
28 my $pkg = q{init::optimize};
30 $conf->add_steps($pkg);
32 my $serialized = $conf->pcfreeze();
34 $conf->options->set( %{$args} );
35 my $step = test_step_constructor_and_description($conf);
36 my $ret = $step->runstep($conf);
37 ok( defined $ret, "runstep() returned defined value" );
39 $conf->replenish($serialized);
41 ########## --optimize  ##########
43 ($args, $step_list_ref) = process_options( {
44     argv => [q{--optimize}],
45     mode => q{configure},
46 } );
47 $conf->options->set( %{$args} );
48 $step = test_step_constructor_and_description($conf);
49 $ret = $step->runstep($conf);
50 ok( defined $ret, "runstep() returned defined value" );
52 $conf->replenish($serialized);
54 ########## --verbose  ##########
56 ($args, $step_list_ref) = process_options( {
57     argv => [q{--verbose}],
58     mode => q{configure},
59 } );
60 $conf->options->set( %{$args} );
61 $step = test_step_constructor_and_description($conf);
63     my $rv;
64     my $stdout;
65     capture ( sub {$rv = $step->runstep($conf) }, \$stdout);
66     ok( defined $rv, "step_name runstep() returned defined value" );
67     ok( $stdout, "verbose output captured" );
70 $conf->replenish($serialized);
72 ########## --optimize=O2  ##########
74 ($args, $step_list_ref) = process_options( {
75     argv => [q{--optimize=O2}],
76     mode => q{configure},
77 } );
78 $conf->options->set( %{$args} );
79 $step = test_step_constructor_and_description($conf);
80 $ret = $step->runstep($conf);
81 ok( defined $ret, "runstep() returned defined value" );
83 $conf->replenish($serialized);
85 ########## --optimize; gcc 3.3  ##########
87 ($args, $step_list_ref) = process_options( {
88     argv => [q{--optimize}],
89     mode => q{configure},
90 } );
91 $conf->options->set( %{$args} );
92 $step = test_step_constructor_and_description($conf);
93 $conf->data->set('gccversion' => '3.3');
94 $ret = $step->runstep($conf);
95 ok( defined $ret, "runstep() returned defined value" );
97 $conf->replenish($serialized);
99 ########## --optimize, --verbose; gcc 4.1 ##########
101 ($args, $step_list_ref) = process_options( {
102     argv => [q{--optimize}, q{--verbose}],
103     mode => q{configure},
104 } );
105 $conf->options->set( %{$args} );
106 $step = test_step_constructor_and_description($conf);
107 $conf->data->set('gccversion' => '4.1');
108 # need to capture the --verbose output,
109 # because the fact that it does not end
110 # in a newline confuses Test::Harness
112       my $rv;
113       my $stdout;
114       capture ( sub {$rv = $step->runstep($conf) }, \$stdout);
115       ok( defined $rv, "runstep() returned defined value" );
116       ok( $stdout, "verbose output captured" );
119 pass("Completed all tests in $0");
121 ################### DOCUMENTATION ###################
123 =head1 NAME
125 init/optimize-01.t - test init::optimize
127 =head1 SYNOPSIS
129     % prove t/steps/init/optimize-01.t
131 =head1 DESCRIPTION
133 The files in this directory test functionality used by F<Configure.pl>.
135 The tests in this file test init::optimize.
137 =head1 AUTHOR
139 James E Keenan
141 =head1 SEE ALSO
143 config::init::optimize, F<Configure.pl>.
145 =cut
147 # Local Variables:
148 #   mode: cperl
149 #   cperl-indent-level: 4
150 #   fill-column: 100
151 # End:
152 # vim: expandtab shiftwidth=4: