Subject: | 11_process.t is unreliable |
When testing "test02.pl error", the test expects that it will always exit with code 25. But when using "die", the exit code is hard to predict: the documentation says:
If an uncaught exception results in interpreter exit, the exit code
is determined from the values of $! and $? with this pseudocode:
exit $! if $!; # errno
exit $? >> 8 if $? >> 8; # child exit status
exit 255; # last resort
which means that your test is essentially guessing at the state of $! and $?, which are globals and affected by multiple factors.
I suggest replacing the two subs in Test02::Command::Error with these:
sub BUILD {
warn 'XXX';
exit 25;
}
sub run {
warn 'YYY';
exit 77;
}