2 # Copyright (C) 2007, Parrot Foundation.
7 use Test::More tests => 28;
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( {
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}],
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}],
60 $conf->options->set( %{$args} );
61 $step = test_step_constructor_and_description($conf);
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}],
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}],
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},
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
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 ###################
125 init/optimize-01.t - test init::optimize
129 % prove t/steps/init/optimize-01.t
133 The files in this directory test functionality used by F<Configure.pl>.
135 The tests in this file test init::optimize.
143 config::init::optimize, F<Configure.pl>.
149 # cperl-indent-level: 4
152 # vim: expandtab shiftwidth=4: