2 # Copyright (C) 2007, The Perl Foundation.
8 use Test::More tests => 24;
10 use lib qw( lib t/configure/testlib );
11 use_ok('config::init::defaults');
12 use_ok('config::auto::gettext');
13 use Parrot::Configure;
14 use Parrot::Configure::Options qw( process_options );
15 use Parrot::Configure::Test qw( test_step_thru_runstep);
16 use IO::CaptureOutput qw| capture |;
19 my $args = process_options(
26 my $conf = Parrot::Configure->new;
28 test_step_thru_runstep( $conf, q{init::defaults}, $args );
30 my $pkg = q{auto::gettext};
32 $conf->add_steps($pkg);
33 $conf->options->set( %{$args} );
35 my ( $task, $step_name, $step);
36 $task = $conf->steps->[-1];
37 $step_name = $task->step;
39 $step = $step_name->new();
40 ok( defined $step, "$step_name constructor returned defined value" );
41 isa_ok( $step, $step_name );
43 # Mock values for OS and C-compiler
44 my ($osname, $cc, $initial_value);
47 $initial_value = $conf->data->get( 'libs' );
48 ok($step->_add_to_libs( {
52 win32_gcc => '-lintl',
53 win32_nongcc => 'intl.lib',
54 default => defined $conf->data->get('glibc') ? '' : '-lintl',
56 "_add_to_libs() returned true value");
57 like($conf->data->get( 'libs' ), qr/-lintl/,
58 "'libs' modified as expected");
59 # Restore value for next test.
60 $conf->data->set( 'libs' => $initial_value );
64 ok($step->_add_to_libs( {
68 win32_gcc => '-lintl',
69 win32_nongcc => 'intl.lib',
70 default => defined $conf->data->get('glibc') ? '' : '-lintl',
72 "_add_to_libs() returned true value");
73 like($conf->data->get( 'libs' ), qr/intl.lib/,
74 "'libs' modified as expected");
75 # Restore value for next test.
76 $conf->data->set( 'libs' => $initial_value );
80 $conf->data->set( glibc => 1 );
81 ok($step->_add_to_libs( {
85 win32_gcc => '-lintl',
86 win32_nongcc => 'intl.lib',
87 default => defined $conf->data->get('glibc') ? '' : '-lintl',
89 "_add_to_libs() returned true value");
90 unlike($conf->data->get( 'libs' ), qr/-lintl/,
91 "'libs' modified as expected");
92 # Restore value for next test.
93 $conf->data->set( 'libs' => $initial_value );
97 $conf->data->set( glibc => undef );
98 ok($step->_add_to_libs( {
102 win32_gcc => '-lintl',
103 win32_nongcc => 'intl.lib',
104 default => defined $conf->data->get('glibc') ? '' : '-lintl',
106 "_add_to_libs() returned true value");
107 like($conf->data->get( 'libs' ), qr/-lintl/,
108 "'libs' modified as expected");
110 my ($test, $verbose);
113 $test = "Hello, world!\n";
115 $has_gettext = $step->_evaluate_cc_run($test, $verbose);
116 is($has_gettext, 1, "Got expected value for has_gettext");
117 is($step->result(), 'yes', "Expected result was set");
118 # Prepare for next test
119 $step->set_result(undef);
123 $test = "Hello, world!\n";
127 $has_gettext = $step->_evaluate_cc_run($test, $verbose);
131 is($has_gettext, 1, "Got expected value for has_gettext");
132 is($step->result(), 'yes', "Expected result was set");
133 like($stdout, qr/\(yes\)/, "Got expected verbose output");
134 # Prepare for next test
135 $step->set_result(undef);
140 $has_gettext = $step->_evaluate_cc_run($test, $verbose);
141 is($has_gettext, 0, "Got expected value for has_gettext");
142 ok(! defined $step->result(), "As expected, result is not yet defined");
145 pass("Completed all tests in $0");
147 ################### DOCUMENTATION ###################
151 auto_gettext-02.t - test config::auto::gettext
155 % prove t/steps/auto_gettext-02.t
159 The files in this directory test functionality used by F<Configure.pl>.
161 The tests in this file test internal method
162 C<auto::gettext::_evaluate_cc_run()>.
170 config::auto::gettext, F<Configure.pl>.
176 # cperl-indent-level: 4
179 # vim: expandtab shiftwidth=4: