nysus has asked for the wisdom of the Perl Monks concerning the following question:
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:
I get the following, which prints the logs, but fails the test:stdout_like { Spin->run; } qr/Loading Spinfile from module/i, 'loads module spinfile';
# 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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How can you get normal log output when testing log output with Test::Output?
by 1nickt (Canon) on Oct 17, 2018 at 21:38 UTC | |
by nysus (Parson) on Oct 17, 2018 at 23:52 UTC |