line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of Config-Model-Tester |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2013-2019 by Dominique Dumont. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The GNU Lesser General Public License, Version 2.1, February 1999 |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
package Config::Model::Tester::Setup 4.005; |
11
|
|
|
|
|
|
|
# ABSTRACT: Common test setup functions for Config::Model |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
14
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
15
|
1
|
|
|
1
|
|
4
|
use locale; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
16
|
1
|
|
|
1
|
|
47
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
17
|
1
|
|
|
1
|
|
23
|
use 5.10.1; |
|
1
|
|
|
|
|
3
|
|
18
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
6
|
use Test::More; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
20
|
1
|
|
|
1
|
|
267
|
use Log::Log4perl 1.11 qw(:easy :levels); |
|
1
|
|
|
|
|
32
|
|
|
1
|
|
|
|
|
8
|
|
21
|
1
|
|
|
1
|
|
760
|
use Path::Tiny; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
22
|
1
|
|
|
1
|
|
670
|
use Getopt::Long; |
|
1
|
|
|
|
|
8637
|
|
|
1
|
|
|
|
|
4
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# use eval so this module does not have a "hard" dependency on Config::Model |
25
|
|
|
|
|
|
|
# This way, Config::Model can build-depend on Config::Model::Tester without |
26
|
|
|
|
|
|
|
# creating a build dependency loop. |
27
|
|
|
|
|
|
|
eval { |
28
|
|
|
|
|
|
|
require Config::Model; |
29
|
|
|
|
|
|
|
require Config::Model::Exception; |
30
|
|
|
|
|
|
|
} ; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
require Exporter; |
33
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
34
|
|
|
|
|
|
|
our @EXPORT = qw(init_test setup_test_dir); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub init_test { |
37
|
0
|
|
|
0
|
1
|
|
my @option_specs = qw/trace error log/; |
38
|
0
|
|
|
|
|
|
push @option_specs, @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
0
|
|
|
|
|
GetOptions( \my %opts, @option_specs) |
41
|
|
|
|
|
|
|
|| die "Unknown option. Expected options are '--".join("', '--",@option_specs)."'\n"; |
42
|
|
|
|
|
|
|
|
43
|
0
|
0
|
|
|
|
|
if ($opts{error}) { |
44
|
0
|
|
|
|
|
|
Config::Model::Exception::Any->Trace(1); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
my $model = Config::Model->new( ); |
48
|
|
|
|
|
|
|
|
49
|
0
|
0
|
|
|
|
|
if ($opts{log}) { |
50
|
0
|
|
|
|
|
|
note("enabling logs"); |
51
|
0
|
|
|
|
|
|
$model->initialize_log4perl; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
else { |
54
|
0
|
|
|
|
|
|
Log::Log4perl->easy_init( $ERROR ); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
ok( $model, "compiled" ); |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
return ($model, $opts{trace}, \%opts); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub setup_test_dir { |
63
|
0
|
|
|
0
|
1
|
|
my %args = @_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $script = path($0); |
66
|
0
|
|
|
|
|
|
my $name = path($0)->basename('.t'); |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $wr_root = path('wr_root')->child($name); |
69
|
0
|
|
|
|
|
|
note("Running tests in $wr_root"); |
70
|
0
|
|
|
|
|
|
$wr_root->remove_tree; |
71
|
0
|
|
|
|
|
|
$wr_root->mkpath; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# TODO: remove stringify once Config::Model::Instance can handle Path::Tiny |
74
|
0
|
0
|
|
|
|
|
return $args{stringify} ? $wr_root->stringify.'/' : $wr_root; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |