I'm using Test::Output to test the output of a module generated by Log::Log4perl. The tests work, but the output of Log::Log4perl is getting suppressed. I can use redirection to get the logs to show on the screen, but then the tests fail. I'm out of random things to try at this point and hoping some a Monk can steer me right. Here is a sample test:

stderr_like { Spin->run; } qr/Loading Spinfile from module/i, 'loads module spinfile';

The above passes. But if I change it to:

stdout_like { Spin->run; } qr/Loading Spinfile from module/i, 'loads module spinfile';
I get the following, which prints the logs, but fails the test:
# Running my tests [INFO ] No Spinfile given in command, looking in current directory. + Spin.Command: 26 [INFO ] No Spinfile found in the current directory, looking in module +share directory. Spin.Command: 33 [INFO ] Loading Spinfile from module share directory + Spin.Command: 36 not ok 1 - loads module spinfile # Failed test 'loads module spinfile' # at t/02-command.t line 31. # STDOUT: # # doesn't match: # (?^i:Loading Spinfile from module) # as expected

I've tried just about everything. The combined_like function does not help. And I've tried all kinds of different way of redirecting stderr/stdin to the point of exhaustion. I'm sure there's probably something simple I can do. Thanks.

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks


In reply to How can you get normal log output when testing log output with Test::Output? by nysus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.