2 # Copyright (C) 2007-2008, Parrot Foundation.
8 use Test::More tests => 23;
11 use_ok('config::auto::pcre');
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 ########## --without-pcre ##########
21 my ($args, $step_list_ref) = process_options(
23 argv => [ q{--without-pcre} ],
28 my $conf = Parrot::Configure::Step::Test->new;
29 $conf->include_config_results( $args );
31 my $serialized = $conf->pcfreeze();
33 my $pkg = q{auto::pcre};
35 $conf->add_steps($pkg);
36 $conf->options->set( %{$args} );
37 my $step = test_step_constructor_and_description($conf);
38 ok( $step->runstep($conf), "runstep() returned true value");
39 is( $step->result(), 'no', "Got expected result" );
40 is( $conf->data->get( 'HAS_PCRE' ), 0,
41 "Got expected value for 'HAS_PCRE'");
43 $conf->replenish($serialized);
45 ########## _select_lib() ##########
47 ($args, $step_list_ref) = process_options( {
51 $conf->add_steps($pkg);
52 $conf->options->set( %{$args} );
53 $step = test_step_constructor_and_description($conf);
55 # Mock values for OS and C-compiler
56 my ($osname, $cc, $initial_value);
60 $initial_value = $conf->data->get( 'libs' );
61 is($step->_select_lib( {
65 win32_nongcc => 'pcre.lib',
69 "_select_lib() returned expected value");
73 $initial_value = $conf->data->get( 'libs' );
74 is($step->_select_lib( {
78 win32_nongcc => 'pcre.lib',
82 "_select_lib() returned expected value");
86 $initial_value = $conf->data->get( 'libs' );
87 is($step->_select_lib( {
91 win32_nongcc => 'pcre.lib',
95 "_select_lib() returned expected value");
97 ########## _evaluate_cc_run() ##########
99 # Mock different outcomes of _evaluate_cc_run
100 my ($test, $has_pcre);
102 $test = q{pcre foobar};
103 ok(! $step->_evaluate_cc_run($conf, $test),
104 "Got expected setting for HAS_PCRE");
107 ok($step->_evaluate_cc_run($conf, $test),
108 "_evaluate_cc_run returned true value as expected");
109 is($step->result(), q{yes, 4.1}, "Got expected PCRE version");
111 $conf->replenish($serialized);
113 ########## --verbose; _evaluate_cc_run() ##########
115 ($args, $step_list_ref) = process_options( {
116 argv => [ q{--verbose} ],
117 mode => q{configure},
119 $conf->add_steps($pkg);
120 $conf->options->set( %{$args} );
121 $step = test_step_constructor_and_description($conf);
123 # Mock different outcomes of _evaluate_cc_run
127 my ($stdout, $stderr);
130 $has_pcre = $step->_evaluate_cc_run($conf, $test);
134 ok($has_pcre, "_evaluate_cc_run returned true value as expected");
135 is($step->result(), q{yes, 4.0}, "Got expected PCRE version");
136 like($stdout, qr/\(yes, 4\.0\)/, "Got expected verbose output");
139 pass("Completed all tests in $0");
141 ################### DOCUMENTATION ###################
145 auto/pcre-01.t - test auto::pcre
149 % prove t/steps/auto/pcre-01.t
153 The files in this directory test functionality used by F<Configure.pl>.
155 The tests in this file test configuration step class auto::pcre.
163 config::auto::pcre, F<Configure.pl>.
169 # cperl-indent-level: 4
172 # vim: expandtab shiftwidth=4: