2 # Copyright (C) 2010, Parrot Foundation.
7 use Test::More tests => 24;
9 use lib qw( lib t/configure/testlib );
10 use_ok('config::auto::zlib');
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 ########## --without-zlib ##########
20 my ($args, $step_list_ref) = process_options(
22 argv => [ q{--without-zlib} ],
27 my $conf = Parrot::Configure::Step::Test->new;
28 $conf->include_config_results( $args );
30 my $pkg = q{auto::zlib};
32 $conf->add_steps($pkg);
34 my $serialized = $conf->pcfreeze();
36 $conf->options->set( %{$args} );
37 my $step = test_step_constructor_and_description($conf);
38 my $ret = $step->runstep($conf);
39 ok( $ret, "runstep() returned true value" );
40 is($conf->data->get('has_zlib'), 0,
41 "Got expected value for 'has_zlib'");
42 is($step->result(), q{no}, "Expected result was set");
44 $conf->replenish($serialized);
46 ########## _select_lib() ##########
48 ($args, $step_list_ref) = process_options( {
52 $conf->options->set( %{$args} );
53 $step = test_step_constructor_and_description($conf);
54 # Mock different OS/compiler combinations.
55 my ($osname, $cc, $initial_libs);
56 $initial_libs = $conf->data->get('libs');
59 is($step->_select_lib( {
63 win32_nongcc => 'zlib.lib',
67 "_select_lib() returned expected value");
71 is($step->_select_lib( {
75 win32_nongcc => 'zlib.lib',
79 "_select_lib() returned expected value");
83 is($step->_select_lib( {
87 win32_nongcc => 'zlib.lib',
91 "_select_lib() returned expected value");
93 $conf->replenish($serialized);
95 ########## --without-zlib; _evaluate_cc_run() ##########
97 ($args, $step_list_ref) = process_options( {
98 argv => [ q{--without-zlib} ],
101 $conf->options->set( %{$args} );
102 $step = test_step_constructor_and_description($conf);
103 my ($test, $has_zlib);
106 $conf->options->set(verbose => undef);
107 $has_zlib = $step->_evaluate_cc_run($conf, $test, $has_zlib);
108 is($has_zlib, 1, "'has_zlib' set as expected");
109 is($step->result(), 'yes, 1.2.3', "Expected result was set");
110 # Prepare for next test
111 $step->set_result(undef);
115 $conf->options->set(verbose => undef);
116 $has_zlib = $step->_evaluate_cc_run($conf, $test, $has_zlib);
117 is($has_zlib, 0, "'has_zlib' set as expected");
118 ok(! defined $step->result(), "Result is undefined, as expected");
124 $conf->options->set(verbose => 1);
127 $step->_evaluate_cc_run($conf, $test, $has_zlib); },
130 is($has_zlib, 1, "'has_zlib' set as expected");
131 is($step->result(), 'yes, 1.2.3', "Expected result was set");
132 like($stdout, qr/\(yes\)/, "Got expected verbose output");
133 # Prepare for next test
134 $step->set_result(undef);
137 pass("Completed all tests in $0");
139 ################### DOCUMENTATION ###################
143 auto/zlib-01.t - test auto::zlib
147 % prove t/steps/auto/zlib-01.t
151 The files in this directory test functionality used by F<Configure.pl>.
153 The tests in this file test auto::zlib.
157 Mostly taken from F<t/steps/auto/gdbm-01.t>.
165 config::auto::zlib, F<Configure.pl>.
171 # cperl-indent-level: 4
174 # vim: expandtab shiftwidth=4: