| 1 |
#!perl -w |
| 2 |
use strict; |
| 3 |
use Imager; |
| 4 |
use Test::More tests => 6; |
| 5 |
|
| 6 |
my $log_name = "testout/t95log.log"; |
| 7 |
|
| 8 |
my $log_message = "test message 12345"; |
| 9 |
|
| 10 |
SKIP: { |
| 11 |
skip("Logging not build", 3) |
| 12 |
unless Imager::i_log_enabled(); |
| 13 |
ok(Imager->open_log(log => $log_name), "open log") |
| 14 |
or diag("Open log: " . Imager->errstr); |
| 15 |
ok(-f $log_name, "file is there"); |
| 16 |
Imager->log($log_message); |
| 17 |
Imager->close_log(); |
| 18 |
|
| 19 |
my $data = ''; |
| 20 |
if (open LOG, "< $log_name") { |
| 21 |
$data = do { local $/; <LOG> }; |
| 22 |
close LOG; |
| 23 |
} |
| 24 |
like($data, qr/\Q$log_message/, "check message made it to the log"); |
| 25 |
} |
| 26 |
|
| 27 |
SKIP: { |
| 28 |
skip("Logging built", 3) |
| 29 |
if Imager::i_log_enabled(); |
| 30 |
|
| 31 |
ok(!Imager->open_log(log => $log_name), "should be no logfile"); |
| 32 |
is(Imager->errstr, "Logging disabled", "check error message"); |
| 33 |
ok(!-f $log_name, "file shouldn't be there"); |
| 34 |
} |