line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Environment; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Test::Environment - Base module for loading Test::Environment::Plugin::* |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use Test::Environment qw{ |
10
|
|
|
|
|
|
|
PostgreSQL |
11
|
|
|
|
|
|
|
Dump |
12
|
|
|
|
|
|
|
}; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# now we have 'psql', 'dump_with_name', ... functions in current namespace. |
15
|
|
|
|
|
|
|
# imported from Test::Environment::Plugin::PostreSQL and Test::Environment::Plugin::Dump |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
eq_or_diff( |
18
|
|
|
|
|
|
|
[ psql( |
19
|
|
|
|
|
|
|
'switches' => '--expanded', |
20
|
|
|
|
|
|
|
'command' => 'SELECT * FROM Table LEFT JOIN OtherTable USING (other_id) ORDER BY other_id;', |
21
|
|
|
|
|
|
|
) ], |
22
|
|
|
|
|
|
|
[ dump_with_name('test_01.dump') ], |
23
|
|
|
|
|
|
|
'check db loading', |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 DESCRIPTION |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
This is the base module to load Test::Environment::Plugin::* modules. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Also sets: |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$ENV{'RUNNING_ENVIRONMENT'} = 'testing'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
The basic idea is to call all the plugins you will need in your testing |
35
|
|
|
|
|
|
|
script. The plugins will export their routines so you can use them in your tests |
36
|
|
|
|
|
|
|
easily. By the $ENV{'RUNNING_ENVIRONMENT'} you can announce that you are running |
37
|
|
|
|
|
|
|
in the testing mode to all the components of your tool. For example MyApp::Config |
38
|
|
|
|
|
|
|
module can decide uppon the %ENV from where to run the configuration file. (for testing |
39
|
|
|
|
|
|
|
look in t/conf/ instead of conf/ for ordinary usage) |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
4
|
|
|
4
|
|
251858
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
161
|
|
44
|
4
|
|
|
4
|
|
24
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
191
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
47
|
|
|
|
|
|
|
|
48
|
4
|
|
|
4
|
|
3829
|
use Carp::Clan; |
|
4
|
|
|
|
|
20917
|
|
|
4
|
|
|
|
|
33
|
|
49
|
4
|
|
|
4
|
|
1792
|
use English '-no_match_vars'; |
|
4
|
|
|
|
|
5044
|
|
|
4
|
|
|
|
|
36
|
|
50
|
4
|
|
|
4
|
|
2160
|
use File::Basename; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
417
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
BEGIN { |
53
|
4
|
|
|
4
|
|
947
|
$ENV{'RUNNING_ENVIRONMENT'} = 'testing'; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 FUNCTIONS |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 import() |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Will load choosen Test::Environment::Plugin::? plugins. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub import { |
66
|
4
|
|
|
4
|
|
44
|
my $package = shift; |
67
|
4
|
|
|
|
|
11
|
my @args = @_; |
68
|
|
|
|
|
|
|
|
69
|
4
|
|
|
|
|
23
|
foreach my $plugin_name (@args) { |
70
|
3
|
50
|
|
|
|
30
|
croak 'bad plugin name' if $plugin_name !~ m{^\w+(::\w+)*$}xms; |
71
|
|
|
|
|
|
|
|
72
|
3
|
|
|
|
|
11
|
my $plugin_module_name = 'Test::Environment::Plugin::'.$plugin_name; |
73
|
3
|
|
|
3
|
|
169
|
eval 'use '.$plugin_module_name.';'; |
|
3
|
|
|
|
|
2450
|
|
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
30
|
|
74
|
3
|
50
|
|
|
|
51
|
if ($EVAL_ERROR) { |
75
|
0
|
|
|
|
|
0
|
croak 'Failed to load "'.$plugin_module_name.'" - '.$EVAL_ERROR; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SEE ALSO |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Test::Environment::Plugin::* L |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 AUTHOR |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Jozef Kutej, Ejkutej@cpan.orgE |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Copyright (C) 2007 by Jozef Kutej |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
96
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.8 or, |
97
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |