summaryrefslogtreecommitdiff
path: root/t/027Watch4.t
blob: 6f61097fb7dd8cfa84d344840547da15da64e2bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/local/bin/perl -w

BEGIN { 
    if($ENV{INTERNAL_DEBUG}) {
        require Log::Log4perl::InternalDebug;
        Log::Log4perl::InternalDebug->enable();
    }
}

use strict;
use warnings;
use Test::More;
use Log::Log4perl::Config::Watch;

plan tests => 4;

my $EG_DIR = "eg";
$EG_DIR = "../eg" unless -d $EG_DIR;

  # sample file to run tests on
my $file = "$EG_DIR/log4j-manual-1.conf";

my $w = Log::Log4perl::Config::Watch->new(
    file   => $file,
    signal => 'USR1',
);

$w->change_detected();
$Log::Log4perl::Config::Watch::L4P_TEST_CHANGE_DETECTED = 0;
$Log::Log4perl::Config::Watch::L4P_TEST_CHANGE_CHECKED  = 0;
$w->change_detected();

is($Log::Log4perl::Config::Watch::L4P_TEST_CHANGE_CHECKED,
   0, "no change checked without signal");
is($Log::Log4perl::Config::Watch::L4P_TEST_CHANGE_DETECTED,
   0, "no change detected without signal");

$w->force_next_check();
$w->change_detected();

is($Log::Log4perl::Config::Watch::L4P_TEST_CHANGE_CHECKED,
   1, "change checked after force_next_check()");
is($Log::Log4perl::Config::Watch::L4P_TEST_CHANGE_DETECTED,
   0, "no change detected after force_next_check()");