| 1 | #! perl |
| 2 | # Copyright (C) 2007, The Perl Foundation. |
| 3 | # $Id: auto_pod2man-01.t 30640 2008-08-29 23:09:28Z jkeenan $ |
| 4 | # auto_pod2man-01.t |
| 5 | |
| 6 | use strict; |
| 7 | use warnings; |
| 8 | use Test::More tests => 32; |
| 9 | use Carp; |
| 10 | use lib qw( lib t/configure/testlib ); |
| 11 | use_ok('config::init::defaults'); |
| 12 | use_ok('config::auto::pod2man'); |
| 13 | use Parrot::BuildUtil; |
| 14 | use Parrot::Configure; |
| 15 | use Parrot::Configure::Options qw( process_options ); |
| 16 | use Parrot::Configure::Test qw( |
| 17 | test_step_thru_runstep |
| 18 | rerun_defaults_for_testing |
| 19 | test_step_constructor_and_description |
| 20 | ); |
| 21 | use IO::CaptureOutput qw| capture |; |
| 22 | |
| 23 | ########## regular ########## |
| 24 | |
| 25 | my ($args, $step_list_ref) = process_options( { |
| 26 | argv => [], |
| 27 | mode => q{configure}, |
| 28 | } ); |
| 29 | |
| 30 | my $conf = Parrot::Configure->new(); |
| 31 | |
| 32 | test_step_thru_runstep($conf, q{init::defaults}, $args); |
| 33 | |
| 34 | my $pkg = q{auto::pod2man}; |
| 35 | |
| 36 | $conf->add_steps($pkg); |
| 37 | |
| 38 | my $serialized = $conf->pcfreeze(); |
| 39 | |
| 40 | $conf->options->set(%{$args}); |
| 41 | my $step = test_step_constructor_and_description($conf); |
| 42 | ok($step->runstep($conf), "runstep() completed successfully"); |
| 43 | ok(defined($step->result), "Result was defined"); |
| 44 | my $has = $conf->data->get('has_pod2man'); |
| 45 | ok( ( ($has == 1) or ($has == 0) ), |
| 46 | "Got an acceptable value for 'has_pod2man'"); |
| 47 | my $new = $conf->data->get('new_pod2man'); |
| 48 | ok( ( ($new == 1) or ($new == 0) ), |
| 49 | "Got an acceptable value for 'new_pod2man'"); |
| 50 | |
| 51 | $conf->replenish($serialized); |
| 52 | |
| 53 | ########## _initial_content_check() ########## |
| 54 | |
| 55 | my $content = undef; |
| 56 | my $rv = $step->_initial_content_check($conf, $content); |
| 57 | ok(! defined $rv, "Got expected return value when content was undefined"); |
| 58 | is($step->result(), |
| 59 | q{no}, "Got expected result when content was undefined"); |
| 60 | |
| 61 | ########## _handle_version() ########## |
| 62 | |
| 63 | my $version; |
| 64 | $version = 0; |
| 65 | ok(auto::pod2man::_handle_version($conf, $version, 'not_a_path'), |
| 66 | "_handle_version() returned true value"); |
| 67 | is($conf->data->get('has_pod2man'), 0, |
| 68 | "Got expected value for 'has_pod2man'"); |
| 69 | is($conf->data->get('new_pod2man'), 0, |
| 70 | "Got expected value for 'new_pod2man'"); |
| 71 | is($conf->data->get('pod2man'), undef, |
| 72 | "... and expected 'pod2man' path"); |
| 73 | |
| 74 | $version = 1; |
| 75 | ok(auto::pod2man::_handle_version($conf, $version, 'path_to_pd'), |
| 76 | "_handle_version() returned true value"); |
| 77 | is($conf->data->get('has_pod2man'), 1, |
| 78 | "Got expected value for 'has_pod2man'"); |
| 79 | is($conf->data->get('new_pod2man'), 0, |
| 80 | "Got expected value for 'new_pod2man'"); |
| 81 | is($conf->data->get('pod2man'), 'path_to_pd', |
| 82 | "... and expected 'pod2man' path"); |
| 83 | |
| 84 | $version = 2; |
| 85 | ok(auto::pod2man::_handle_version($conf, $version, 'another_path_to_pd'), |
| 86 | "_handle_version() returned true value"); |
| 87 | is($conf->data->get('has_pod2man'), 1, |
| 88 | "Got expected value for 'has_pod2man'"); |
| 89 | is($conf->data->get('new_pod2man'), 1, |
| 90 | "Got expected value for 'new_pod2man'"); |
| 91 | is($conf->data->get('pod2man'), 'another_path_to_pd', |
| 92 | "... and expected 'pod2man' path"); |
| 93 | |
| 94 | ########## _handle_old_pod2man() ########## |
| 95 | |
| 96 | $version = $step->_handle_old_pod2man(); |
| 97 | is($version, 1, "Got expected version setting for old pod2man"); |
| 98 | is($step->result(), q{yes, old version}, |
| 99 | "Got expected result when old pod2man"); |
| 100 | |
| 101 | ########## _handle_no_pod2man() ########## |
| 102 | |
| 103 | $version = $step->_handle_no_pod2man(); |
| 104 | is($version, 0, "Got expected version setting for no pod2man"); |
| 105 | is($step->result(), q{failed}, "Got expected result when no pod2man"); |
| 106 | |
| 107 | pass("Completed all tests in $0"); |
| 108 | |
| 109 | ################### DOCUMENTATION ################### |
| 110 | |
| 111 | =head1 NAME |
| 112 | |
| 113 | auto_pod2man-01.t - test auto::pod2man |
| 114 | |
| 115 | =head1 SYNOPSIS |
| 116 | |
| 117 | % prove t/steps/auto_pod2man-01.t |
| 118 | |
| 119 | =head1 DESCRIPTION |
| 120 | |
| 121 | The files in this directory test functionality used by F<Configure.pl>. |
| 122 | |
| 123 | The tests in this file test auto::pod2man. |
| 124 | |
| 125 | =head1 AUTHOR |
| 126 | |
| 127 | Reini Urban |
| 128 | |
| 129 | =head1 SEE ALSO |
| 130 | |
| 131 | config::auto::pod2man, F<Configure.pl>. |
| 132 | |
| 133 | =cut |
| 134 | |
| 135 | # Local Variables: |
| 136 | # mode: cperl |
| 137 | # cperl-indent-level: 4 |
| 138 | # fill-column: 100 |
| 139 | # End: |
| 140 | # vim: expandtab shiftwidth=4: |