"be consistent" | |
PerlMonks |
Unit test of script fails unless Test::Warnings is used?!by wanna_code_perl (Friar) |
on Oct 13, 2019 at 00:38 UTC ( [id://11107390]=perlquestion: print w/replies, xml ) | Need Help?? |
wanna_code_perl has asked for the wisdom of the Perl Monks concerning the following question: Fellow Monks! I have a script in my latest distribution that I am adding unit tests for. I've gone with the simple caller approach: bin/script:
This script exits with no warnings and normal status when require'd via perl -Ibin -e 'require "script";', but die()s as expected when run directly from the commandline. t/bin/load.t:
When run via make test, I get bin/load.t ........ skipped: (no reason given) and 255 exit status. When run via prove bin/load.t, I get the same:
I don't know why it's failing. Interestingly, it only failed when I started removing extraneous use lines from bin/load.t. Removing Test::Warnings was the one that stopped it from working! If the use Test::Warnings ':all'; line is uncommented, the test script succeeds. The BEGIN block seemingly makes no difference. The results are the same if the code is run outside of BEGIN { ... }. Also, if I add a die to the top of bin/script it (correctly) fails with the BAIL_OUT() message from bin/load.t. So the abnormal exit has me confused. Why is it failing, and how do I fix it? I guess the success under Test::Warnings should be a clue, but I would expect the tests to be more sensitive to warnings when Test::Warnings is included (due to the extra test it adds), not less sensitive.
Back to
Seekers of Perl Wisdom
|
|