tagged release 0.6.4
[parrot.git] / t / steps / auto_crypto-03.t
blob180479e30bc5e6cc4d5ae129ca92c98ec0cb9f40
1 #! perl
2 # Copyright (C) 2008, The Perl Foundation.
3 # $Id$
5 use strict;
6 use warnings;
7 use Test::More tests =>  16;
8 use Carp;
9 use Cwd;
10 use lib qw( lib t/configure/testlib );
11 use_ok('config::init::defaults');
12 use_ok('config::auto::crypto');
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 |;
18 my $args = process_options(
19     {
20         argv => [ q{--without-crypto} ],
21         mode => q{configure},
22     }
25 my $conf = Parrot::Configure->new;
27 test_step_thru_runstep( $conf, q{init::defaults}, $args );
29 my $pkg = q{auto::crypto};
31 $conf->add_steps($pkg);
32 $conf->options->set( %{$args} );
34 my ($task, $step_name, $step);
35 $task        = $conf->steps->[-1];
36 $step_name   = $task->step;
38 $step = $step_name->new();
39 ok( defined $step, "$step_name constructor returned defined value" );
40 isa_ok( $step, $step_name );
43 my ($test, $has_crypto, $verbose);
45 $test = qq{OpenSSL 0.9.9z\n};
46 $has_crypto = 0;
47 $verbose = undef;
48 $has_crypto = $step->_evaluate_cc_run($conf, $test, $has_crypto, $verbose);
49 is($has_crypto, 1, "'has_crypto' set as expected");
50 is($step->result(), 'yes, 0.9.9z', "Expected result was set");
51 # Prepare for next test
52 $step->set_result(undef);
54 $test = qq{foobar};
55 $has_crypto = 0;
56 $verbose = undef;
57 $has_crypto = $step->_evaluate_cc_run($conf, $test, $has_crypto, $verbose);
58 is($has_crypto, 0, "'has_crypto' set as expected");
59 ok(! defined $step->result(), "Result is undefined, as expected");
62     my $stdout;
63     $test = qq{OpenSSL 0.9.9z\n};
64     $has_crypto = 0;
65     $verbose = 1;
66     capture(
67         sub { $has_crypto =
68             $step->_evaluate_cc_run($conf, $test, $has_crypto, $verbose); },
69         \$stdout,
70     );
71     is($has_crypto, 1, "'has_crypto' set as expected");
72     is($step->result(), 'yes, 0.9.9z', "Expected result was set");
73     like($stdout, qr/\(yes\)/, "Got expected verbose output");
74     # Prepare for next test
75     $step->set_result(undef);
78 pass("Completed all tests in $0");
80 ################### DOCUMENTATION ###################
82 =head1 NAME
84 auto_crypto-03.t - test config::auto::crypto
86 =head1 SYNOPSIS
88     % prove t/steps/auto_crypto-03.t
90 =head1 DESCRIPTION
92 The files in this directory test functionality used by F<Configure.pl>.
94 The tests in this file test config::auto::crypto.
96 =head1 HISTORY
98 Mostly taken from F<t/steps/auto_gdbm-03.t>.
100 =head1 AUTHOR
102 Francois Perrad
104 =head1 SEE ALSO
106 config::auto::crypto, F<Configure.pl>.
108 =cut
110 # Local Variables:
111 #   mode: cperl
112 #   cperl-indent-level: 4
113 #   fill-column: 100
114 # End:
115 # vim: expandtab shiftwidth=4: