line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Clustericious::Config; |
2
|
|
|
|
|
|
|
|
3
|
9
|
|
|
9
|
|
29643
|
use strict; |
|
9
|
|
|
|
|
40
|
|
|
9
|
|
|
|
|
306
|
|
4
|
9
|
|
|
9
|
|
48
|
use warnings; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
213
|
|
5
|
9
|
|
|
9
|
|
105
|
use v5.10; |
|
9
|
|
|
|
|
36
|
|
|
9
|
|
|
|
|
756
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
9
|
50
|
|
9
|
|
49
|
unless($INC{'File/HomeDir/Test.pm'}) |
9
|
|
|
|
|
|
|
{ |
10
|
9
|
|
|
9
|
|
740
|
eval q{ use File::HomeDir::Test }; |
|
9
|
|
|
|
|
9145
|
|
|
9
|
|
|
|
|
295904
|
|
|
9
|
|
|
|
|
264
|
|
11
|
9
|
50
|
|
|
|
7877
|
die $@ if $@; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
9
|
|
|
9
|
|
8212
|
use File::HomeDir; |
|
9
|
|
|
|
|
48159
|
|
|
9
|
|
|
|
|
679
|
|
16
|
9
|
|
|
9
|
|
7284
|
use YAML::XS qw( DumpFile ); |
|
9
|
|
|
|
|
27783
|
|
|
9
|
|
|
|
|
590
|
|
17
|
9
|
|
|
9
|
|
74
|
use File::Path qw( mkpath ); |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
420
|
|
18
|
9
|
|
|
9
|
|
5252
|
use Clustericious::Config; |
|
9
|
|
|
|
|
33
|
|
|
9
|
|
|
|
|
304
|
|
19
|
9
|
|
|
9
|
|
8196
|
use Mojo::Loader; |
|
9
|
|
|
|
|
12768
|
|
|
9
|
|
|
|
|
85
|
|
20
|
|
|
|
|
|
|
|
21
|
9
|
|
|
9
|
|
311
|
use base qw( Test::Builder::Module Exporter ); |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
7336
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our @EXPORT = qw( create_config_ok create_directory_ok home_directory_ok create_config_helper_ok ); |
24
|
|
|
|
|
|
|
our @EXPORT_OK = @EXPORT; |
25
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => \@EXPORT ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $config_dir; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _init |
30
|
|
|
|
|
|
|
{ |
31
|
9
|
|
|
9
|
|
86
|
$config_dir = File::HomeDir->my_home . "/etc"; |
32
|
9
|
|
|
|
|
2360
|
mkdir $config_dir; |
33
|
|
|
|
|
|
|
|
34
|
9
|
|
|
|
|
76
|
$ENV{CLUSTERICIOUS_CONF_DIR} = $config_dir; |
35
|
9
|
|
|
|
|
85
|
Clustericious::Config->_testing(1); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
9
|
|
|
9
|
|
93425
|
BEGIN { _init() } |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# ABSTRACT: Test Clustericious::Config |
41
|
|
|
|
|
|
|
our $VERSION = '0.28'; # VERSION |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub create_config_ok ($;$$) |
45
|
|
|
|
|
|
|
{ |
46
|
9
|
|
|
9
|
1
|
3083
|
my($config_name, $config, $test_name) = @_; |
47
|
|
|
|
|
|
|
|
48
|
9
|
|
|
|
|
33
|
my $fn = "$config_name.conf"; |
49
|
9
|
|
|
|
|
37
|
$fn =~ s/::/-/g; |
50
|
|
|
|
|
|
|
|
51
|
9
|
100
|
|
|
|
41
|
unless(defined $config) |
52
|
|
|
|
|
|
|
{ |
53
|
1
|
|
|
|
|
25
|
my $loader = Mojo::Loader->new; |
54
|
1
|
|
|
|
|
11
|
my $caller = caller; |
55
|
1
|
|
|
|
|
7
|
$loader->load($caller); |
56
|
1
|
|
|
|
|
705
|
$config = $loader->data($caller, "etc/$fn"); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
9
|
|
|
|
|
218
|
my $tb = __PACKAGE__->builder; |
60
|
9
|
|
|
|
|
169
|
my $ok = 1; |
61
|
9
|
50
|
|
|
|
42
|
unless(defined $config) |
62
|
|
|
|
|
|
|
{ |
63
|
0
|
|
|
|
|
0
|
$config = "---\n"; |
64
|
0
|
|
|
|
|
0
|
$tb->diag("unable to locate text for $config_name"); |
65
|
0
|
|
|
|
|
0
|
$ok = 0; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
9
|
|
|
|
|
38
|
my $config_filename = "$config_dir/$fn"; |
69
|
|
|
|
|
|
|
|
70
|
9
|
|
|
|
|
21
|
eval { |
71
|
9
|
100
|
|
|
|
40
|
if(ref $config) |
72
|
|
|
|
|
|
|
{ |
73
|
3
|
|
|
|
|
15
|
DumpFile($config_filename, $config); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
else |
76
|
|
|
|
|
|
|
{ |
77
|
6
|
|
|
|
|
787
|
open my $fh, '>', $config_filename; |
78
|
6
|
|
|
|
|
113
|
print $fh $config; |
79
|
6
|
|
|
|
|
389
|
close $fh; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
}; |
82
|
9
|
50
|
|
|
|
921
|
if(my $error = $@) |
83
|
|
|
|
|
|
|
{ |
84
|
0
|
|
|
|
|
0
|
$ok = 0; |
85
|
0
|
|
|
|
|
0
|
$tb->diag("exception: $error"); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
9
|
|
33
|
|
|
91
|
$test_name //= "create config for $config_name at $config_filename"; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# remove any cached copy if necessary |
91
|
9
|
|
|
|
|
100
|
Clustericious::Config->_uncache($config_name); |
92
|
|
|
|
|
|
|
|
93
|
9
|
|
|
|
|
50
|
$tb->ok($ok, $test_name); |
94
|
9
|
|
|
|
|
5814
|
return $config_filename; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub create_directory_ok ($;$) |
99
|
|
|
|
|
|
|
{ |
100
|
1
|
|
|
1
|
1
|
3
|
my($path, $test_name) = @_; |
101
|
|
|
|
|
|
|
|
102
|
1
|
|
|
|
|
3
|
my $fullpath = $path; |
103
|
1
|
|
|
|
|
5
|
$fullpath =~ s{^/}{}; |
104
|
1
|
|
|
|
|
12
|
$fullpath = join('/', File::HomeDir->my_home, $fullpath); |
105
|
1
|
|
|
|
|
548
|
mkpath $fullpath, 0, 0700; |
106
|
|
|
|
|
|
|
|
107
|
1
|
|
33
|
|
|
9
|
$test_name //= "create directory $fullpath"; |
108
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
10
|
my $tb = __PACKAGE__->builder; |
110
|
1
|
|
|
|
|
30
|
$tb->ok(-d $fullpath, $test_name); |
111
|
1
|
|
|
|
|
397
|
return $fullpath; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub home_directory_ok (;$) |
116
|
|
|
|
|
|
|
{ |
117
|
2
|
|
|
2
|
1
|
1122
|
my($test_name) = @_; |
118
|
|
|
|
|
|
|
|
119
|
2
|
|
|
|
|
56
|
my $fullpath = File::HomeDir->my_home; |
120
|
|
|
|
|
|
|
|
121
|
2
|
|
33
|
|
|
88
|
$test_name //= "home directory $fullpath"; |
122
|
|
|
|
|
|
|
|
123
|
2
|
|
|
|
|
14
|
my $tb = __PACKAGE__->builder; |
124
|
2
|
|
|
|
|
52
|
$tb->ok(-d $fullpath, $test_name); |
125
|
2
|
|
|
|
|
958
|
return $fullpath; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub create_config_helper_ok ($$;$) |
130
|
|
|
|
|
|
|
{ |
131
|
1
|
|
|
1
|
1
|
19
|
my($helper_name, $helper_code, $test_name) = @_; |
132
|
|
|
|
|
|
|
|
133
|
1
|
|
33
|
|
|
11
|
$test_name //= "create config helper $helper_name"; |
134
|
|
|
|
|
|
|
|
135
|
1
|
|
|
|
|
11
|
require Clustericious::Config::Helpers; |
136
|
1
|
|
|
|
|
2
|
do { |
137
|
9
|
|
|
9
|
|
73
|
no strict 'refs'; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
1031
|
|
138
|
1
|
|
|
|
|
3
|
*{"Clustericious::Config::Helpers::$helper_name"} = $helper_code; |
|
1
|
|
|
|
|
12
|
|
139
|
|
|
|
|
|
|
}; |
140
|
1
|
|
|
|
|
5
|
push @Clustericious::Config::Helpers::EXPORT, $helper_name; |
141
|
|
|
|
|
|
|
|
142
|
1
|
|
|
|
|
17
|
my $tb = __PACKAGE__->builder; |
143
|
1
|
|
|
|
|
26
|
$tb->ok(1, $test_name); |
144
|
1
|
|
|
|
|
831
|
return; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
__END__ |