tagged release 0.6.4
[parrot.git] / t / steps / auto_crypto-02.t
blob617ec01f9db17cedb31c7e1fa3617cf8f30f1ef4
1 #! perl
2 # Copyright (C) 2008, The Perl Foundation.
3 # $Id$
5 use strict;
6 use warnings;
7 use Test::More tests => 24;
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 => [ ],
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 );
42 # Mock different OS/compiler combinations.
43 my ($osname, $cc, $initial_libs);
44 $initial_libs = $conf->data->get('libs');
45 $osname = 'mswin32';
46 $cc = 'gcc';
47 ok($step->_add_to_libs( {
48     conf            => $conf,
49     osname          => $osname,
50     cc              => $cc,
51     win32_nongcc    => 'libcrypto.lib',
52     default         => '-lcrypto',
53 } ),
54    "_add_to_libs() returned true value");
55 like($conf->data->get('libs'),
56     qr/-lcrypto/,
57     "'libs' attribute modified as expected");
58 # Restore setting for next test
59 $conf->data->set( libs => $initial_libs );
61 $osname = 'mswin32';
62 $cc = 'cc';
63 ok($step->_add_to_libs( {
64     conf            => $conf,
65     osname          => $osname,
66     cc              => $cc,
67     win32_nongcc    => 'libcrypto.lib',
68     default         => '-lcrypto',
69 } ),
70    "_add_to_libs() returned true value");
71 like($conf->data->get('libs'),
72     qr/libcrypto.lib/,
73     "'libs' attribute modified as expected");
74 # Restore setting for next test
75 $conf->data->set( libs => $initial_libs );
77 $osname = 'foobar';
78 $cc = 'cc';
79 ok($step->_add_to_libs( {
80     conf            => $conf,
81     osname          => $osname,
82     cc              => $cc,
83     win32_nongcc    => 'libcrypto.lib',
84     default         => '-lcrypto',
85 } ),
86    "_add_to_libs() returned true value");
87 like($conf->data->get('libs'),
88     qr/-lcrypto/,
89     "'libs' attribute modified as expected");
90 # Restore setting for next test
91 $conf->data->set( libs => $initial_libs );
93 my ($libs, $ccflags, $linkflags, $verbose);
95 $libs = q{-lalpha};
96 $ccflags = q{-Ibeta};
97 $linkflags = q{-Lgamma};
98 $verbose = undef;
99 $step->_recheck_settings($conf, $libs, $ccflags, $linkflags, $verbose);
100 like($conf->data->get('libs'), qr/$libs/,
101     "Got expected value for 'libs'");
102 like($conf->data->get('ccflags'), qr/$ccflags/,
103     "Got expected value for 'ccflags'");
104 like($conf->data->get('linkflags'), qr/$linkflags/,
105     "Got expected value for 'linkflags'");
106 is($step->result, 'no', "Expected result was set");
109     my $stdout;
110     $libs = q{-lalpha};
111     $ccflags = q{-Ibeta};
112     $linkflags = q{-Lgamma};
113     $verbose = 1;
114     capture(
115         sub { $step->_recheck_settings(
116             $conf, $libs, $ccflags, $linkflags, $verbose); },
117         \$stdout,
118     );
119     like($conf->data->get('libs'), qr/$libs/,
120         "Got expected value for 'libs'");
121     like($conf->data->get('ccflags'), qr/$ccflags/,
122         "Got expected value for 'ccflags'");
123     like($conf->data->get('linkflags'), qr/$linkflags/,
124         "Got expected value for 'linkflags'");
125     is($step->result, 'no', "Expected result was set");
126     like($stdout, qr/\(no\)/, "Got expected verbose output");
129 pass("Completed all tests in $0");
131 ################### DOCUMENTATION ###################
133 =head1 NAME
135 auto_crypto-02.t - test config::auto::crypto
137 =head1 SYNOPSIS
139     % prove t/steps/auto_crypto-02.t
141 =head1 DESCRIPTION
143 The files in this directory test functionality used by F<Configure.pl>.
145 The tests in this file test config::auto::crypto.
147 =head1 HISTORY
149 Mostly taken from F<t/steps/auto_gdbm-04.t>.
151 =head1 AUTHOR
153 Francois Perrad
155 =head1 SEE ALSO
157 config::auto::crypto, F<Configure.pl>.
159 =cut
161 # Local Variables:
162 #   mode: cperl
163 #   cperl-indent-level: 4
164 #   fill-column: 100
165 # End:
166 # vim: expandtab shiftwidth=4: