Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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
% 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)'
# 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


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.

Replies are listed 'Best First'.
Re: Otherwise successful test fails under test_harness (-t)
by tye (Sage) 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;

      In Bob We Trust, All Others Bring Data.

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://953271]
Approved by ww
Front-paged by ww
[Corion]: marto: Ow! I would assume there is a cron job monitoring the free disk space and automatically opening a ticket at 90%, 95% and 100% usage...
[Corion]: Even we had automatic emails back when we maintained the machine ourselves...
[marto]: Corion you under estimate how lazy these admins are :P
[Discipulus]: we too; using opsview alarms
[marto]: the key word: outsourcing ;)
[Corion]: marto: Yeah, feels like that ;) You could set up the cronjob that auto-creates tickets :-))
[marto]: the ticketing system does not accept calls via email, nor has it a working API. It's tied into Active Directory for authentication and the Solaris boxes aren't on that domain
[Corion]: The one thing I haven't figured out a solution to is how to get an edge-trigger instead of sending an email every 5 minutes if the usage is above 90%. I want one mail when it goes over 90% but no more emails as long as it stays between 90% and 95%.
[Corion]: marto: Clever! ;)
[Corion]: You can only reach me by pager

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2017-01-24 10:08 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (203 votes). Check out past polls.