tagged release 0.6.4
[parrot.git] / t / steps / auto_gdbm-03.t
blobab64ae135b2acc6224c975f3f5cdd8552326ca83
1 #! perl
2 # Copyright (C) 2007, The Perl Foundation.
3 # $Id$
4 # auto_gdbm-03.t
6 use strict;
7 use warnings;
8 use Test::More tests =>  16;
9 use Carp;
10 use Cwd;
11 use lib qw( lib t/configure/testlib );
12 use_ok('config::init::defaults');
13 use_ok('config::auto::gdbm');
14 use Parrot::Configure;
15 use Parrot::Configure::Options qw( process_options );
16 use Parrot::Configure::Test qw( test_step_thru_runstep);
17 use IO::CaptureOutput qw| capture |;
19 my $args = process_options(
20     {
21         argv => [ q{--without-gdbm} ],
22         mode => q{configure},
23     }
26 my $conf = Parrot::Configure->new;
28 test_step_thru_runstep( $conf, q{init::defaults}, $args );
30 my $pkg = q{auto::gdbm};
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 );
44 my ($test, $has_gdbm, $verbose);
46 $test = qq{gdbm is working.\n};
47 $has_gdbm = 0;
48 $verbose = undef;
49 $has_gdbm = $step->_evaluate_cc_run($test, $has_gdbm, $verbose);
50 is($has_gdbm, 1, "'has_gdbm' set as expected");
51 is($step->result(), 'yes', "Expected result was set");
52 # Prepare for next test
53 $step->set_result(undef);
55 $test = qq{foobar};
56 $has_gdbm = 0;
57 $verbose = undef;
58 $has_gdbm = $step->_evaluate_cc_run($test, $has_gdbm, $verbose);
59 is($has_gdbm, 0, "'has_gdbm' set as expected");
60 ok(! defined $step->result(), "Result is undefined, as expected");
63     my $stdout;
64     $test = qq{gdbm is working.\n};
65     $has_gdbm = 0;
66     $verbose = 1;
67     capture(
68         sub { $has_gdbm =
69             $step->_evaluate_cc_run($test, $has_gdbm, $verbose); },
70         \$stdout,
71     );
72     is($has_gdbm, 1, "'has_gdbm' set as expected");
73     is($step->result(), 'yes', "Expected result was set");
74     like($stdout, qr/\(yes\)/, "Got expected verbose output");
75     # Prepare for next test
76     $step->set_result(undef);
79 pass("Completed all tests in $0");
81 ################### DOCUMENTATION ###################
83 =head1 NAME
85 auto_gdbm-03.t - test config::auto::gdbm
87 =head1 SYNOPSIS
89     % prove t/steps/auto_gdbm-03.t
91 =head1 DESCRIPTION
93 The files in this directory test functionality used by F<Configure.pl>.
95 The tests in this file test config::auto::gdbm.
97 =head1 AUTHOR
99 James E Keenan
101 =head1 SEE ALSO
103 config::auto::gdbm, F<Configure.pl>.
105 =cut
107 # Local Variables:
108 #   mode: cperl
109 #   cperl-indent-level: 4
110 #   fill-column: 100
111 # End:
112 # vim: expandtab shiftwidth=4: