File: 03_reload.t

package info (click to toggle)
liblog-dispatch-config-perl 1.04-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 224 kB
  • sloc: perl: 233; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 821 bytes parent folder | download | duplicates (2)
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
use strict;
use Test::More;

use Log::Dispatch::Config;
use FileHandle;
use File::Copy;
use File::Temp qw(tempfile);
use IO::Scalar;

if( $^O eq 'MSWin32' ) {
    plan skip_all => 'These tests fail in Win32 for silly reasons';
}
else {
    plan tests => 5;
}
my($fh, $file) = tempfile;
copy("t/foo.cfg", $file);

Log::Dispatch::Config->configure_and_watch($file);

{
    my $disp = Log::Dispatch::Config->instance;
    isa_ok $disp->{outputs}->{foo}, 'Log::Dispatch::File';

    sleep 1;

    copy("t/bar.cfg", $file);

    local $^W;
    my $disp2 = Log::Dispatch::Config->instance;
    isa_ok $disp2->{outputs}->{bar}, 'Log::Dispatch::File';
    is $disp2->{outputs}->{foo}, undef;
    isnt "$disp", "$disp2", "$disp - $disp2";

    my $disp3 = Log::Dispatch::Config->instance;
    is "$disp2", "$disp3", 'same one';
}