File: 030-log.t

package info (click to toggle)
libimager-perl 1.027%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,820 kB
  • sloc: perl: 32,971; ansic: 28,092; makefile: 52; cpp: 4
file content (34 lines) | stat: -rw-r--r-- 832 bytes parent folder | download | duplicates (7)
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
#!perl -w
use strict;
use Imager;
use Test::More tests => 6;

my $log_name = "testout/t95log.log";

my $log_message = "test message 12345";

SKIP: {
  skip("Logging not build", 3)
    unless Imager::i_log_enabled();
  ok(Imager->open_log(log => $log_name), "open log")
    or diag("Open log: " . Imager->errstr);
  ok(-f $log_name, "file is there");
  Imager->log($log_message);
  Imager->close_log();

  my $data = '';
  if (open LOG, "< $log_name") {
    $data = do { local $/; <LOG> };
    close LOG;
  }
  like($data, qr/\Q$log_message/, "check message made it to the log");
}

SKIP: {
  skip("Logging built", 3)
    if Imager::i_log_enabled();

  ok(!Imager->open_log(log => $log_name), "should be no logfile");
  is(Imager->errstr, "Logging disabled", "check error message");
  ok(!-f $log_name, "file shouldn't be there");
}