diff options
Diffstat (limited to 't/027Watch4.t')
-rwxr-xr-x | t/027Watch4.t | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/t/027Watch4.t b/t/027Watch4.t new file mode 100755 index 0000000..6f61097 --- /dev/null +++ b/t/027Watch4.t @@ -0,0 +1,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()"); |