/
028-option_or_data.t
96 lines (70 loc) · 2.16 KB
/
028-option_or_data.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#! perl
# Copyright (C) 2007, Parrot Foundation.
# 028-option_or_data.t
use strict;
use warnings;
use Test::More tests => 12;
use Carp;
use lib qw( lib );
use lib qw( config );
use init::defaults;
use init::install;
use Parrot::Configure;
use Parrot::Configure::Options qw( process_options );
use Parrot::Configure::Test qw( test_step_thru_runstep);
use Parrot::Configure::Step::List qw( get_steps_list );
$| = 1;
is( $|, 1, "output autoflush is set" );
my $testopt = q{bindir};
my $testoptval = q{mybindir};
my $localargv = [];
my ($args, $step_list_ref) = process_options(
{
mode => q{configure},
argv => $localargv,
}
);
ok( defined $args, "process_options returned successfully" );
my $conf = Parrot::Configure->new;
test_step_thru_runstep( $conf, q{init::defaults}, $args );
my ( $task, $step_name, $step, $ret );
my $pkg = q{init::install};
$conf->add_steps($pkg);
$conf->options->set( %{$args} );
$task = $conf->steps->[1];
$step_name = $task->step;
$step = $step_name->new();
ok( defined $step, "$step_name constructor returned defined value" );
isa_ok( $step, $step_name );
ok( $step->description(), "$step_name has description" );
$ret = $step->runstep($conf);
ok( defined $ret, "$step_name runstep() returned defined value" );
my $val = $conf->option_or_data($testopt);
is(
$val,
$conf->data->get($testopt),
'option_or_data() returned expected value when no option provided'
);
pass("Completed all tests in $0");
################### DOCUMENTATION ###################
=head1 NAME
028-option_or_data.t - test C<Parrot::Configure::option_or_data()>
=head1 SYNOPSIS
% prove t/configure/028-option_or_data.t
=head1 DESCRIPTION
The files in this directory test functionality used by F<Configure.pl>.
This file tests C<Parrot::Configure::option_or_data()> in the case where
no value for the tested option has been set on the command line but a
value for the tested option has been located internally by a
configuration step.
=head1 AUTHOR
James E Keenan
=head1 SEE ALSO
Parrot::Configure, F<Configure.pl>.
=cut
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: