line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Install::TestVars; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
67315
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
47
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01_02'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use base qw(Module::Install::Base); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
1153
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
2493
|
use Getopt::Long; |
|
1
|
|
|
|
|
74003
|
|
|
1
|
|
|
|
|
12
|
|
11
|
1
|
|
|
1
|
|
10133
|
use Term::ReadLine; |
|
1
|
|
|
|
|
3175
|
|
|
1
|
|
|
|
|
34
|
|
12
|
1
|
|
|
1
|
|
845
|
use Term::UI; |
|
1
|
|
|
|
|
116606
|
|
|
1
|
|
|
|
|
38
|
|
13
|
1
|
|
|
1
|
|
1267
|
use Text::ASCIITable; |
|
1
|
|
|
|
|
65378
|
|
|
1
|
|
|
|
|
679
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub test_vars { |
16
|
0
|
|
|
0
|
1
|
|
my ( $self, %config ) = @_; |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
my $is_help = 0; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
GetOptions( 'help|h' => \$is_help, ); |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my $term = Term::ReadLine->new('test_vars'); |
23
|
0
|
|
0
|
|
|
|
my $out = $term->OUT || \*STDOUT; |
24
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
|
if ($is_help) { |
26
|
0
|
|
|
|
|
|
print $out 'Options: ', "\n\n"; |
27
|
0
|
|
|
|
|
|
for my $var ( keys %config ) { |
28
|
0
|
|
0
|
|
|
|
$config{$var}->{prompt} ||= $var; |
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
print $out sprintf( |
31
|
|
|
|
|
|
|
" %s : %s%s\n", |
32
|
|
|
|
|
|
|
$var, |
33
|
|
|
|
|
|
|
$config{$var}->{prompt}, |
34
|
|
|
|
|
|
|
( |
35
|
|
|
|
|
|
|
exists $config{$var}->{default} |
36
|
|
|
|
|
|
|
? sprintf( " (default: %s)", $config{$var}->{default} ) |
37
|
|
|
|
|
|
|
: "" |
38
|
|
|
|
|
|
|
) |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
0
|
|
|
|
|
|
exit; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
WIZARD: |
45
|
0
|
|
|
|
|
|
my %test_vars = map { ( split( /=/, $_, 2 ) ) } @ARGV; |
|
0
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $tbl = Text::ASCIITable->new( +{ headingText => 'test variables' } ); |
47
|
0
|
|
|
|
|
|
$tbl->setCols( 'key', 'value' ); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
print $out "Test configuration variables, \n\n"; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
for my $var ( keys %config ) { |
52
|
0
|
0
|
|
|
|
|
unless ( exists $test_vars{$var} ) { |
53
|
0
|
|
0
|
|
|
|
$config{$var}->{prompt} ||= 'Input ' . $var; |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
0
|
|
|
|
my %args = ( |
|
|
0
|
|
|
|
|
|
56
|
|
|
|
|
|
|
(exists $config{$var}->{default}) |
57
|
|
|
|
|
|
|
? ( |
58
|
|
|
|
|
|
|
prompt => $config{$var}{prompt}, |
59
|
|
|
|
|
|
|
default => $config{$var}{default}, |
60
|
|
|
|
|
|
|
) : ( |
61
|
|
|
|
|
|
|
prompt => $config{$var}{prompt}, |
62
|
|
|
|
|
|
|
), |
63
|
|
|
|
|
|
|
( exists $config{$var}->{choices} && ref $config{$var}->{choices} ) |
64
|
|
|
|
|
|
|
? ( |
65
|
|
|
|
|
|
|
choices => $config{$var}{choices}, |
66
|
|
|
|
|
|
|
print_me => 'Choise number' |
67
|
|
|
|
|
|
|
) : (), |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
do { |
71
|
0
|
|
|
|
|
|
$test_vars{$var} = $term->get_reply(%args); |
72
|
0
|
0
|
|
|
|
|
$test_vars{$var} = $config{$var}{choices}->[$test_vars{$var} - 1] if (ref $config{$var}{choices}); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} until ( defined $test_vars{$var} ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else { |
78
|
0
|
|
|
|
|
|
print $out sprintf( "%s: %s\n", $var, $test_vars{$var} ); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$tbl->addRow( $var, $test_vars{$var} ); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
print $out "\n", $tbl, "\n"; |
85
|
|
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
|
unless ( |
87
|
|
|
|
|
|
|
$term->ask_yn( |
88
|
|
|
|
|
|
|
prompt => 'Check configuration, proceed?', |
89
|
|
|
|
|
|
|
default => 'y' |
90
|
|
|
|
|
|
|
) |
91
|
|
|
|
|
|
|
) |
92
|
|
|
|
|
|
|
{ |
93
|
0
|
|
|
|
|
|
goto WIZARD; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
%MY::TEST_VARS = (%test_vars); |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
package MY; |
100
|
|
|
|
|
|
|
our %TEST_VARS = (); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub test { |
103
|
0
|
|
|
0
|
|
|
my ( $self, %attrs ) = @_; |
104
|
0
|
|
|
|
|
|
my $vars = 'TEST_VARS=' |
105
|
|
|
|
|
|
|
. join( |
106
|
0
|
|
|
|
|
|
' ' => map { sprintf( '%s=%s', $_, $TEST_VARS{$_} ) } |
107
|
|
|
|
|
|
|
keys %TEST_VARS |
108
|
|
|
|
|
|
|
); |
109
|
0
|
|
|
|
|
|
my $section = $self->SUPER::test(%attrs); |
110
|
0
|
|
|
|
|
|
$section = $vars . "\n" . $section; |
111
|
0
|
0
|
|
|
|
|
$section =~ s|(PERL_DL_NONLAZY=1)|$1 \$\(TEST_VARS\)|g if ( length $vars ); |
112
|
0
|
|
|
|
|
|
$section; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
116
|
|
|
|
|
|
|
__END__ |