belg4mit has asked for the wisdom of the Perl Monks concerning the following question:
The test script at the bottom, is part of a soon to be released update to IO::Pager, once I can solve this problem. The tests behave as expected when invoked from the command line, but fail when invoked via make test or the equivalent command that invokes:
unrelated checks to see if we are connected to a TTY.
% perl -Mblib t/9-open.t ok 1 - PAGER undefined since find_pager() ok 2 - Could not create pipe 1..2 % perl -MExtUtils::Command::MM -e "test_harness (1, 'blib/lib', 'blib/arch' ) " t/9-open.t #-w gives no insight either t/9-open.t .. not ok 1 - PAGER undefined since find_pager() # Failed test 'PAGER undefined since find_pager()' # at t/9-open.t line 10. # '' # doesn't match '(?-xism:The PAGER environment variable is not defined)' not ok 2 - Could not create pipe # Failed test 'Could not create pipe' # at t/9-open.t line 14. # '' # doesn't match '(?-xism:Could not pipe to PAGER)' 1..2 # Looks like you failed 2 tests of 2. Dubious, test returned 2 (wstat 512, 0x200) Failed 2/2 subtests Test Summary Report ------------------- t/9-open.t (Wstat: 512 Tests: 2 Failed: 2) Failed tests: 1-2 Non-zero exit status: 2 Files=1, Tests=2, 0 wallclock secs ( 0.05 usr 0.01 sys + 0.23 cusr 0.02 csys = 0.31 CPU) Result: FAIL Failed 1/1 test programs. 2/2 subtests failed.The test script
If you want the whole environment to debug, you can access the code at https://github.com/fangly/io-pager/use strict; use warnings; use Test::More; use t::TestUtils; use IO::Pager; undef $ENV{PAGER}; eval{ my $token = new IO::Pager }; like($@, qr/The PAGER environment variable is not defined/, 'PAGER und +efined since find_pager()'); $ENV{PAGER} = '/dev/null'; eval{ my $token = new IO::Pager or die $!}; like($@, qr/Could not pipe to PAGER/, 'Could not create pipe'); done_testing;
TIA!
UPDATE: To clarify, these tests are purposefully setting up conditions for object instantiation to fail, and verifying that the expected/documented errors occur. Nothing really happens in the intervening code, other than seemingly
--
In Bob We Trust, All Others Bring Data.
Back to
Seekers of Perl Wisdom