line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Env; |
2
|
2
|
|
|
2
|
|
74539
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
76
|
|
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use vars qw(@EXPORT $VERSION); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
115
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
13
|
use Exporter qw(import); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
114
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
@EXPORT = qw(env_ok); |
9
|
|
|
|
|
|
|
$VERSION = '1.086'; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
23
|
use Test::Builder; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
419
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $Test = Test::Builder->new(); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=encoding utf8 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Test::Env - test the environment |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Test::More tests => 1; |
24
|
|
|
|
|
|
|
use Test::Env; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
env_ok( 'PERL5LIB', "./blib/lib" ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 Functions |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=over 4 |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item env_ok( NAME, VALUE ) |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Ok if the environment variable NAME is VALUE. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub env_ok($$) { |
41
|
3
|
|
|
3
|
1
|
7422
|
my $name = shift; |
42
|
3
|
|
|
|
|
9
|
my $value = shift; |
43
|
|
|
|
|
|
|
|
44
|
3
|
100
|
|
|
|
17
|
unless( exists $ENV{$name} ) { |
|
|
100
|
|
|
|
|
|
45
|
1
|
|
|
|
|
5
|
$Test->ok(0); |
46
|
1
|
|
|
|
|
866
|
$Test->diag( "Environment variable [$name] missing!\n", |
47
|
|
|
|
|
|
|
"\tExpected [$value]\n" ); |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
0
|
elsif( $ENV{$name} ne $value ) { |
50
|
1
|
|
|
|
|
6
|
$Test->ok(0); |
51
|
1
|
|
|
|
|
945
|
$Test->diag( "Environment variable [$name] has wrong value!\n", |
52
|
|
|
|
|
|
|
"\tExpected [$value]\n", |
53
|
|
|
|
|
|
|
"\tGot [$ENV{$name}]\n" ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else |
56
|
|
|
|
|
|
|
{ |
57
|
1
|
|
|
|
|
8
|
$Test->ok(1); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=back |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SOURCE AVAILABILITY |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
This source is in GitHub: |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
https://github.com/briandfoy/test-env |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 AUTHOR |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
brian d foy, C<< >> |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Copyright © 2002-2022, brian d foy . All rights reserved. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
78
|
|
|
|
|
|
|
it under the terms of the Artistic License 2.0. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
"Roscoe"; |