My code has a test for a bad API call, fortunately that code results in a warning from the module itself. But when I’m testing the failed API call I want to not see the warning in TAP.
t/01-pass.t .............. ok
t/02-fail.t .............. ok
t/03-noversion.t ......... ok
t/04-no-file.t ........... ok
Use of uninitialized value $file in concatenation (.) or string at /home/xenoterracide/projects/Test-Version/lib/Test/Version.pm line 29.
t/05-file-not-defined.t .. ok
# unsorted oks: 001
t/06-all.t ............... ok
All tests successful.
Files=6, Tests=37, 1 wallclock secs ( 0.04 usr 0.02 sys + 0.35 cusr 0.04 csys = 0.45 CPU)
Result: PASS
Here’s the actual code
#!/usr/bin/perl
use 5.006;
use strict;
use warnings;
use Test::Tester tests => 7;
use Test::Version qw( version_ok );
check_test(
sub {
version_ok; # correct call version_ok( $file )
},
{
ok => 0,
name => 'check version in ',
diag => 'FILE_NOT_DEFINED',
},
'$file not defined'
);
is there any way to squelch the warning and prevent to prevent it from ending up in TAP (outside of no warnings in the original module).
will silence warnings temporarily.