Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Otherwise successful test fails under test_harness

by belg4mit (Prior)
on Feb 12, 2012 at 01:51 UTC ( #953271=perlquestion: print w/ replies, xml ) Need Help??
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:
% 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
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;
If you want the whole environment to debug, you can access the code at https://github.com/fangly/io-pager/

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 unrelated checks to see if we are connected to a TTY.

--
In Bob We Trust, All Others Bring Data.

Comment on Otherwise successful test fails under test_harness
Download Code
Re: Otherwise successful test fails under test_harness
by Anonymous Monk on Feb 12, 2012 at 02:13 UTC

    I'm curious to know what happens with  prove -vb t/9-open.t

      A colorized version of the output make test gives.

      --
      In Bob We Trust, All Others Bring Data.

Re: Otherwise successful test fails under test_harness (-t)
by tye (Cardinal) on Feb 12, 2012 at 02:43 UTC

    Since the output is going through a pipe to a summarizing program, I'm not surprised that IO::Pager doesn't even try to launch a pager and so it doesn't fail because it never even checks whether $ENV{PAGER} is set.

    - tye        

      While cryptic, and not exactly correct—see the UPDATE appended to my post before I received this reply, in short: there is no launching of a pager—this did get me to insert some print statements and compare the output in the two scenarios. The heart of the problem was indeed the lack of TTY, and a cryptic line from 8 years ago that I no longer grok the intent of:
      # This allows us to have multiple pseudo-STDOUT return 0 unless -t STDOUT;
      Thanks!

      --
      In Bob We Trust, All Others Bring Data.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://953271]
Approved by ww
Front-paged by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2014-09-22 00:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (176 votes), past polls