2 # Copyright (C) 2007, Parrot Foundation.
8 use Test::More tests => 24;
10 use lib qw( lib t/configure/testlib );
11 use_ok('config::auto::env');
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 ########### regular ###########
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::env};
31 $conf->add_steps($pkg);
33 my $serialized = $conf->pcfreeze();
35 $conf->options->set(%{$args});
36 my $step = test_step_constructor_and_description($conf);
37 ok($step->runstep($conf), "runstep() returned true value");
39 $conf->replenish($serialized);
41 ########### _evaluate_env() ###########
43 ($args, $step_list_ref) = process_options( {
47 $conf->options->set(%{$args});
48 $step = test_step_constructor_and_description($conf);
49 my ($setenv, $unsetenv);
52 $step->_evaluate_env($conf, $setenv, $unsetenv);
53 is($step->result(), q{both}, "Got expected result");
56 $step->_evaluate_env($conf, $setenv, $unsetenv);
57 is($step->result(), q{setenv}, "Got expected result");
60 $step->_evaluate_env($conf, $setenv, $unsetenv);
61 is($step->result(), q{unsetenv}, "Got expected result");
64 $step->_evaluate_env($conf, $setenv, $unsetenv);
65 is($step->result(), q{no}, "Got expected result");
67 $conf->replenish($serialized);
69 ########### --verbose; _evaluate_env() ###########
71 ($args, $step_list_ref) = process_options( {
72 argv => [ q{--verbose} ],
75 $conf->options->set(%{$args});
76 $step = test_step_constructor_and_description($conf);
82 sub { $step->_evaluate_env($conf, $setenv, $unsetenv) },
85 like($stdout, qr/both/, "Got expected verbose output");
86 is($step->result(), q{both}, "Got expected result");
93 sub { $step->_evaluate_env($conf, $setenv, $unsetenv) },
96 like($stdout, qr/setenv/, "Got expected verbose output");
97 is($step->result(), q{setenv}, "Got expected result");
104 sub { $step->_evaluate_env($conf, $setenv, $unsetenv) },
107 like($stdout, qr/unsetenv/, "Got expected verbose output");
108 is($step->result(), q{unsetenv}, "Got expected result");
115 sub { $step->_evaluate_env($conf, $setenv, $unsetenv) },
118 like($stdout, qr/no/, "Got expected verbose output");
119 is($step->result(), q{no}, "Got expected result");
122 pass("Completed all tests in $0");
124 ################### DOCUMENTATION ###################
128 auto/env-01.t - test auto::env
132 % prove t/steps/auto/env-01.t
136 The files in this directory test functionality used by F<Configure.pl>.
138 The tests in this file test auto::env.
146 config::auto::env, F<Configure.pl>.
152 # cperl-indent-level: 4
155 # vim: expandtab shiftwidth=4: