tagged release 0.6.4
[parrot.git] / t / steps / auto_revision-01.t
blob6febc0845ac3e7739ddedb3c1e2ad1f305133845
1 #! perl
2 # Copyright (C) 2007, The Perl Foundation.
3 # $Id$
4 # auto_revision-01.t
6 use strict;
7 use warnings;
8 use Test::More tests => 20;
9 use Carp;
10 use lib qw( lib t/configure/testlib );
11 use_ok('config::init::defaults');
12 use_ok('config::auto::revision');
13 use Parrot::Configure;
14 use Parrot::Configure::Options qw( process_options );
15 use Parrot::Configure::Test qw( test_step_thru_runstep);
17 my $args = process_options(
18     {
19         argv => [ ],
20         mode => q{configure},
21     }
24 my $conf = Parrot::Configure->new;
26 test_step_thru_runstep( $conf, q{init::defaults}, $args );
28 my $pkg = q{auto::revision};
30 $conf->add_steps($pkg);
31 $conf->options->set( %{$args} );
33 my ( $task, $step_name, $step);
34 $task        = $conf->steps->[1];
35 $step_name   = $task->step;
37 $step = $step_name->new();
38 ok( defined $step, "$step_name constructor returned defined value" );
39 isa_ok( $step, $step_name );
40 ok( $step->description(), "$step_name has description" );
42 my ($testrev, $ret);
44     $testrev = 99999;
45     local $Parrot::Revision::current = $testrev;
46     $ret = $step->runstep($conf);
47     ok( $ret, "$step_name runstep() returned true value" );
48     is($conf->data->get('revision'), $testrev,
49         "'revision' element was set correctly");
50     is($step->result(), qq{r$testrev}, "Expected result was set");
54     $testrev = 0;
55     local $Parrot::Revision::current = $testrev;
56     $ret = $step->runstep($conf);
57     ok( $ret, "$step_name runstep() returned true value" );
58     is($conf->data->get('revision'), $testrev,
59         "'revision' element was set correctly");
60     is($step->result(), q{done}, "Expected result was set");
64     $testrev = q{foobar};
65     local $Parrot::Revision::current = $testrev;
66     eval { $ret = $step->runstep($conf); };
67     like($@, qr/Cannot use non-numeric revision number/,
68         "Got expected error message");
72     $testrev = undef;
73     local $Parrot::Revision::current = $testrev;
74     $ret = $step->runstep($conf);
75     ok( $ret, "$step_name runstep() returned true value" );
76     ok(! defined($conf->data->get('revision')),
77         "'revision' element is undefined as expected");
78     is($step->result(), q{done}, "Expected result was set");
81 pass("Completed all tests in $0");
83 ################### DOCUMENTATION ###################
85 =head1 NAME
87 auto_revision-01.t - test config::auto::revision
89 =head1 SYNOPSIS
91     % prove t/steps/auto_revision-01.t
93 =head1 DESCRIPTION
95 The files in this directory test functionality used by F<Configure.pl>.
97 The tests in this file test subroutines exported by config::auto::revision.
99 =head1 AUTHOR
101 James E Keenan
103 =head1 SEE ALSO
105 config::auto::revision, F<Configure.pl>.
107 =cut
109 # Local Variables:
110 #   mode: cperl
111 #   cperl-indent-level: 4
112 #   fill-column: 100
113 # End:
114 # vim: expandtab shiftwidth=4: