With the advent of intensive coverage tests and zealous Perl::Critic policies, testing even simple things is getting messy.
even a moundain: print 'hello' ; triggers the wrath of InputOutput::RequireCheckedSyscalls with the message "Return value of flagged function ignored". This is not new, the problem and discussion have been around for, hmm, centuries. If one can't call a system function on a system handle, chances are hell broke loose and Finland won the european song contest another time. There is no chance that P::C could know I'm writting on a system handle that would require a static analysis that would take ages. If possible at all. Also, someone could select another filehandle and there might be disk space shortage or the filehandle could be close or any other state that would make our friendly 'print' fail. OK, let's stop going round this. It's an error to not check the return value so let's just do that. Of course a well place 'no critic' would have calmed the zealous policy but we like to do things right here. Next problem is coverage. Nothing upsets me more than a 99.8% coverage. I'd almost prefere a 80% coverage to 99.8%. So I tried to test that case with { use IO::File; my $current_fh = select ; my $fh = new IO::File; # not opened select $fh ; throws_ok { $object->DoPrint() ; } qr/can't print!/, 'print failed' ; select $current_fh ; } with DoPrint looking something like: print 'hi' or carp q{can't print!} ; It may look silly to give a string to carp, that carp is goign to display and probably have the same problem with but someone may be catching all these nasty exception that never happend (do I hear someone say that this kind of sentence almost guaranty that exception during the first customer demo?) Of course this doesn't work. First, Test::NoWarnings feast on yout terminal forcing you to scroll for half an hour before wou make sense of the mess that failed tests dump on your terminal. This is not the test framework fault, it's the terminal (do I miss 1980 borlan IDE where the messages were neatly packed till you clicked on them to see details) Second, the test passes!! t/011_interaction....NOK 13/0# Failed test 'print failed' # at t/011_interaction.t line 147. # expecting: Regexp ((?-xism:can't print!)) # found: normal exit Obviously I'm doing something wrong. Has someone ever bothered with this test? Is there a better way to do it? Has someone written a test module to do that? Cheers, Nadim.