fixing the original filename path
[cxgn-corelibs.git] / t / CXGN / debug.t
blobf35f2c64dbb2e59e6549bcc8d032b7445127cbee
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use English;
6 use CXGN::Config;
7 use Test::More tests => 7;
8 use Test::Warn;
10 BEGIN {
11 use_ok( 'CXGN::Debug' )
12 or BAIL_OUT('could not include the module being tested');
16 my $conf_debug = CXGN::Config->load->{'debug'};
19 local $ENV{CXGN_DEBUG} = 1;
20 my $d = CXGN::Debug->new;
21 warning_like {
22 $d->debug('this is a test debug message');
23 } qr/this is a test debug message/, 'debug() emits when CXGN_DEBUG is set to 1';
24 warning_like {
25 $d->d('this is a test debug message');
26 } qr/this is a test debug message/, 'same thing with d()';
30 # NOTE: since currently there is no programmatic way to alter the
31 # VHost conf vars at runtime, have to settle for less-than complete
32 # testing of CXGN::Debug's response to the debug conf variable
34 SKIP: {
35 skip 'debug conf var is set, cannot test silence of Debug in absence of either set variable', 2
36 if $conf_debug;
38 local $ENV{CXGN_DEBUG};
39 delete $ENV{CXGN_DEBUG};
41 my $d = CXGN::Debug->new;
42 warning_is {
43 $d->debug('this is a test debug message');
44 } undef, "debug() does not emit when both conf debug and CXGN_DEBUG env var are false";
45 warning_like {
46 $d->d('this is a test debug message');
47 } undef, 'same thing with d()';
52 local $ENV{CXGN_DEBUG} = 0;
53 my $d = CXGN::Debug->new;
54 warning_is {
55 $d->debug('this is a test debug message');
56 } undef, "debug() does not emit when CXGN_DEBUG is set to 0";
57 warning_like {
58 $d->d('this is a test debug message');
59 } undef, 'same thing with d()';