line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
1
|
|
|
1
|
|
181950
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
64
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
926
|
use Test::More tests => 29; |
|
1
|
|
|
|
|
24608
|
|
|
1
|
|
|
|
|
10
|
|
5
|
1
|
|
|
1
|
|
2726
|
use Test::Exception; |
|
1
|
|
|
|
|
3847
|
|
|
1
|
|
|
|
|
5
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
276
|
use File::Path; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
79
|
|
8
|
1
|
|
|
1
|
|
287
|
use Path::Class; |
|
1
|
|
|
|
|
82204
|
|
|
1
|
|
|
|
|
50
|
|
9
|
1
|
|
|
1
|
|
3521
|
use File::Slurp qw/ write_file /; |
|
1
|
|
|
|
|
13761
|
|
|
1
|
|
|
|
|
518
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
1617
|
use Data::Dumper; |
|
1
|
|
|
|
|
14456
|
|
|
1
|
|
|
|
|
77
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
431
|
use lib "lib"; |
|
1
|
|
|
|
|
545
|
|
|
1
|
|
|
|
|
5
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
150281
|
use_ok("Devel::PerlySense::Config::Project"); |
|
1
|
|
|
|
|
574
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
18
|
|
16
|
1
|
|
|
1
|
|
294
|
use_ok("Devel::PerlySense"); |
|
1
|
|
|
|
|
1423
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
|
|
268
|
ok( |
23
|
|
|
|
|
|
|
my $oPerlySense = Devel::PerlySense->new(), |
24
|
|
|
|
|
|
|
"New PerlySense object ok", |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
194
|
my $dir = "t/data/config"; |
29
|
1
|
|
|
|
|
3
|
my $dirTemp = "$dir/temp"; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
5
|
note("Creating temp dir"); |
32
|
1
|
|
|
|
|
201
|
rmtree($dirTemp); |
33
|
1
|
|
|
|
|
172
|
mkpath($dirTemp); |
34
|
1
|
|
|
|
|
8
|
ok(-e $dirTemp, "Temp dir created ok"); |
35
|
|
|
|
|
|
|
END { |
36
|
1
|
|
|
1
|
|
4
|
note("Removing temp dir"); |
37
|
1
|
|
|
|
|
914
|
rmtree($dirTemp); |
38
|
1
|
|
|
|
|
10
|
ok( ! -e $dirTemp, "Temp file gone"); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
197
|
ok( |
44
|
|
|
|
|
|
|
my $oConfig = Devel::PerlySense::Config::Project->new(), |
45
|
|
|
|
|
|
|
"Created config in temp dir ok", |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
1
|
|
|
|
|
211
|
is_deeply($oConfig->rhConfig, {}, "Empty config"); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
throws_ok( |
53
|
|
|
|
|
|
|
sub { |
54
|
1
|
|
|
1
|
|
28
|
$oConfig->loadConfig(dirRoot => $dirTemp); |
55
|
|
|
|
|
|
|
}, |
56
|
1
|
|
|
|
|
404
|
qr/Could not open config file .t.data.config.temp..PerlySenseProject.project.yml./, |
57
|
|
|
|
|
|
|
"Can't load nonexisting config file ok", |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
|
|
405
|
is_deeply($oConfig->rhConfig, {}, " Empty config"); |
61
|
1
|
|
|
|
|
392
|
is($oConfig->dirRoot, undef, " No dirRoot set"); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
219
|
ok( ! -e "dirTemp/.PerlySenseProject", "No project dir"); |
65
|
1
|
|
|
|
|
190
|
ok( |
66
|
|
|
|
|
|
|
$oConfig->createFileConfigDefault(dirRoot => $dirTemp), |
67
|
|
|
|
|
|
|
"Created new project config", |
68
|
|
|
|
|
|
|
); |
69
|
1
|
|
|
|
|
227
|
like( |
70
|
|
|
|
|
|
|
$oConfig->dirRoot, |
71
|
|
|
|
|
|
|
qr/t.data.config.temp$/, |
72
|
|
|
|
|
|
|
"dirRoot set to the new location", |
73
|
|
|
|
|
|
|
); |
74
|
1
|
|
|
|
|
202
|
ok(-e "$dirTemp/.PerlySenseProject", "Project dir created"); |
75
|
1
|
|
|
|
|
190
|
ok(-e "$dirTemp/.PerlySenseProject/project.yml", "Project config file created"); |
76
|
1
|
|
|
|
|
180
|
is(scalar keys %{$oConfig->rhConfig}, 5, " Loaded config"); |
|
1
|
|
|
|
|
26
|
|
77
|
1
|
|
|
|
|
210
|
is( |
78
|
|
|
|
|
|
|
$oConfig->rhConfig->{run_file}->[0]->{moniker}, |
79
|
|
|
|
|
|
|
"Test", |
80
|
|
|
|
|
|
|
"Sample key in structure is correct", |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
479
|
ok( |
85
|
|
|
|
|
|
|
$oConfig->createFileCriticDefault(dirRoot => $dirTemp), |
86
|
|
|
|
|
|
|
"Created new project Perl::Critic config", |
87
|
|
|
|
|
|
|
); |
88
|
1
|
|
|
|
|
481
|
ok(-e "$dirTemp/.PerlySenseProject/.perlcritic", "Perl::Critic config file created"); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
388
|
note("Re-create, rename file"); |
95
|
1
|
|
|
|
|
689
|
my $globBackupProject = file("$dirTemp/.PerlySenseProject/project.yml") . ".*"; |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
892
|
ok($oConfig->rhConfig->{run_file}->[0]->{moniker} = "Blah", "Changed moniker"); |
98
|
1
|
|
|
|
|
541
|
ok( |
99
|
|
|
|
|
|
|
$oConfig->createFileConfigDefault(dirRoot => $dirTemp), |
100
|
|
|
|
|
|
|
"Created new project config", |
101
|
|
|
|
|
|
|
); |
102
|
1
|
|
|
|
|
899
|
my @aFileBackup = glob($globBackupProject); |
103
|
1
|
50
|
|
|
|
5
|
is( |
104
|
|
|
|
|
|
|
scalar @aFileBackup, |
105
|
|
|
|
|
|
|
1, |
106
|
|
|
|
|
|
|
"Original Project config file renamed", |
107
|
|
|
|
|
|
|
) or warn("GLOB ($globBackupProject)\n"); |
108
|
1
|
|
|
|
|
432
|
like( |
109
|
|
|
|
|
|
|
$oConfig->dirRoot, |
110
|
|
|
|
|
|
|
qr/t.data.config.temp$/, |
111
|
|
|
|
|
|
|
"dirRoot set to the new location", |
112
|
|
|
|
|
|
|
); |
113
|
1
|
|
|
|
|
412
|
is( |
114
|
|
|
|
|
|
|
$oConfig->rhConfig->{run_file}->[0]->{moniker}, |
115
|
|
|
|
|
|
|
"Test", |
116
|
|
|
|
|
|
|
"Sample key in structure is correct", |
117
|
|
|
|
|
|
|
); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
985
|
my $globBackupCritic = file("$dirTemp/.PerlySenseProject/.perlcritic") . ".*"; |
122
|
|
|
|
|
|
|
|
123
|
1
|
|
|
|
|
247
|
ok( |
124
|
|
|
|
|
|
|
$oConfig->createFileCriticDefault(dirRoot => $dirTemp), |
125
|
|
|
|
|
|
|
"Created new Critic config", |
126
|
|
|
|
|
|
|
); |
127
|
1
|
|
|
|
|
293
|
my @aFileBackupCritic = glob($globBackupCritic); |
128
|
1
|
50
|
|
|
|
6
|
is( |
129
|
|
|
|
|
|
|
scalar @aFileBackupCritic, |
130
|
|
|
|
|
|
|
1, |
131
|
|
|
|
|
|
|
"Original Critic config file renamed", |
132
|
|
|
|
|
|
|
) or warn("GLOB ($globBackupCritic)\n"); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
1
|
|
|
|
|
197
|
note("Create another one"); |
137
|
1
|
|
|
|
|
1000077
|
sleep(1); |
138
|
1
|
|
|
|
|
23
|
ok( |
139
|
|
|
|
|
|
|
$oConfig->createFileConfigDefault(dirRoot => $dirTemp), |
140
|
|
|
|
|
|
|
"Created new project config", |
141
|
|
|
|
|
|
|
); |
142
|
1
|
|
|
|
|
381
|
@aFileBackup = glob("$dirTemp/.PerlySenseProject/project.yml.*"); |
143
|
1
|
|
|
|
|
5
|
is( |
144
|
|
|
|
|
|
|
scalar @aFileBackup, |
145
|
|
|
|
|
|
|
2, |
146
|
|
|
|
|
|
|
"Original Project config file renamed", |
147
|
|
|
|
|
|
|
); |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
#parse config file with syntax error |
152
|
1
|
|
|
|
|
212
|
my $fileConfig = file($dirTemp, $oConfig->nameFileConfig) . ""; |
153
|
1
|
|
|
|
|
134
|
write_file($fileConfig, "lskdjf sdf this isn't YAML at all\n\n"); |
154
|
|
|
|
|
|
|
throws_ok( |
155
|
1
|
|
|
1
|
|
32
|
sub { $oConfig->loadConfig(dirRoot => $dirTemp); }, |
156
|
1
|
|
|
|
|
168
|
qr/Could not read \.PerlySense Project config file \(.+?\): YAML::Tiny /, |
157
|
|
|
|
|
|
|
"Died correctly on invalid YAML", |
158
|
|
|
|
|
|
|
); |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
__END__ |