2 # Copyright (C) 2007, Parrot Foundation.
8 use Test::More tests => 38;
10 use lib qw( lib t/configure/testlib );
11 use_ok('config::auto::msvc');
12 use Parrot::Configure::Options qw( process_options );
13 use Parrot::Configure::Step::Test;
14 use Parrot::Configure::Test qw(
15 test_step_constructor_and_description
17 use IO::CaptureOutput qw| capture |;
19 ########## Win32 ##########
21 my ($args, $step_list_ref) = process_options( {
26 my $conf = Parrot::Configure::Step::Test->new;
27 $conf->include_config_results( $args );
29 my $pkg = q{auto::msvc};
31 $conf->add_steps($pkg);
33 my $serialized = $conf->pcfreeze();
35 $conf->options->set(%{$args});
36 my $step = test_step_constructor_and_description($conf);
38 skip 'MSVC is Windows only', 1 unless $^O =~ /Win32/i;
39 ok($step->runstep($conf), "runstep() returned true value");
42 $conf->replenish($serialized);
44 ########## _evaluate_msvc() ##########
46 ($args, $step_list_ref) = process_options( {
50 $conf->options->set(%{$args});
51 $step = test_step_constructor_and_description($conf);
52 my $msvcref = { _MSC_VER => 1399 };
53 ok($step->_evaluate_msvc($conf, $msvcref),
54 "_evaluate_msvc returned true value");
55 is($step->result, 'yes, 13.99', "Got expected result");
56 is($conf->data->get('msvcversion'), '13.99',
57 "Got expected msvc version string");
59 $conf->replenish($serialized);
61 ########## _evaluate_msvc() ##########
63 ($args, $step_list_ref) = process_options( {
67 $conf->options->set(%{$args});
68 $step = test_step_constructor_and_description($conf);
69 $msvcref = { _MSC_VER => 1400 };
70 ok($step->_evaluate_msvc($conf, $msvcref),
71 "_evaluate_msvc returned true value");
72 is($step->result, 'yes, 14.0', "Got expected result");
73 is($conf->data->get('msvcversion'), '14.0',
74 "Got expected msvc version string");
76 $conf->data->get('ccflags'),
77 qr/\-D_CRT_SECURE_NO_DEPRECATE/,
78 "ccflags appropriately adjusted given MSVC version"
81 $conf->replenish($serialized);
83 ########## _handle_not_msvc() ##########
85 ($args, $step_list_ref) = process_options( {
89 $conf->options->set(%{$args});
90 $step = test_step_constructor_and_description($conf);
92 my ($status, $major, $minor, $verbose);
96 $status = $step->_handle_not_msvc($conf, $major, $minor);
97 ok(! defined $status, 'sub return value, as expected, not yet set');
98 ok(! $step->result(), 'result, as expected, not yet set');
102 $status = $step->_handle_not_msvc($conf, $major, $minor);
103 ok($status, 'sub return value, as expected, set to true value');
104 is($step->result(), q{no}, 'Got expected result');
105 ok(! defined ($conf->data->get( 'msvcversion' )),
106 'msvcversion is undef, as expected');
110 $status = $step->_handle_not_msvc($conf, $major, $minor);
111 ok($status, 'sub return value, as expected, set to true value');
112 is($step->result(), q{no}, 'Got expected result');
113 ok(! defined ($conf->data->get( 'msvcversion' )),
114 'msvcversion is undef, as expected');
116 $conf->replenish($serialized);
118 ########## _handle_not_msvc() ##########
120 ($args, $step_list_ref) = process_options( {
121 argv => [ q{--verbose=1} ],
122 mode => q{configure},
124 $conf->options->set(%{$args});
132 $step->_handle_not_msvc($conf, $major, $minor); },
135 ok($status, 'sub return value, as expected, set to true value');
136 is($step->result(), q{no}, 'Got expected result');
137 ok(! defined ($conf->data->get( 'msvcversion' )),
138 'msvcversion is undef, as expected');
139 like($stdout, qr/\(no\)/, "Got expected verbose output");
140 # Prepare for the next test.
141 $step->set_result(undef);
144 ########## _compose_msvcversion() ##########
150 $msvcversion = $step->_compose_msvcversion($major, $minor);
151 is($msvcversion, '13.99', "Got expected MSVC version");
152 is($step->result(), 'yes, 13.99', "Got expected result");
153 $step->set_result(undef);
161 $step->_compose_msvcversion($major, $minor); },
164 is($msvcversion, '13.99', "Got expected MSVC version");
165 is($step->result(), 'yes, 13.99', "Got expected result");
166 $step->set_result(undef);
169 pass("Completed all tests in $0");
171 ################### DOCUMENTATION ###################
175 auto/msvc-01.t - test auto::msvc
179 % prove t/steps/auto/msvc-01.t
183 The files in this directory test functionality used by F<Configure.pl>.
185 The tests in this file test auto::msvc. Some tests run only if the system is
194 config::auto::msvc, F<Configure.pl>.
200 # cperl-indent-level: 4
203 # vim: expandtab shiftwidth=4: