Skip Menu |

This queue is for tickets about the Test-Output CPAN distribution.

Report information
The Basics
Id: 118235
Status: open
Priority: 0/
Queue: Test-Output

People
Owner: Nobody in particular
Requestors: dpchrist [...] holgerdanske.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: stderr_like() gives false positive if coderef invokes Carp::cluck()
Date: Sun, 2 Oct 2016 22:02:06 -0700
To: bug-Test-Output [...] rt.cpan.org
From: David Christensen <dpchrist [...] holgerdanske.com>
bug-Test-Output: Thank you for Test::Output -- it's a very useful module. :-) I was creating test scripts using Test::Output::stderr_like(), when I noticed that a test case was passing that should have failed. I did some trouble-shooting, and it appears that: 1. stderr_like() gets confused if coderef calls Carp::cluck(). 2. stderr_like() appears to work correctly if coderef calls 'print STDERR ...', warn(), or Carp::carp(). Please see the following console session for details. Please let me know if you need more information. TIA, David 2016-10-02 21:33:46 dpchrist@t7400 ~/sandbox/perl $ cat /etc/debian_version 7.11 2016-10-02 21:34:12 dpchrist@t7400 ~/sandbox/perl $ uname -a Linux t7400 3.2.0-4-amd64 #1 SMP Debian 3.2.81-2 x86_64 GNU/Linux 2016-10-02 21:34:14 dpchrist@t7400 ~/sandbox/perl $ perl -v This is perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-linux-gnu-thread-multi (with 102 registered patches, see perl -V for more detail) Copyright 1987-2011, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page. 2016-10-02 21:35:26 dpchrist@t7400 ~/sandbox/perl $ perl -MTest::Output -e 'print $Test::Output::VERSION, "\n"' 1.03 2016-10-02 21:35:36 dpchrist@t7400 ~/sandbox/perl $ perl -MCarp -e 'print $Carp::VERSION, "\n"' 1.38 2016-10-02 21:59:50 dpchrist@t7400 ~/sandbox/perl $ cat Test-Output-stderr_like-Carp-cluck-bug.t #!/usr/bin/perl # $Id: Test-Output-stderr_like-Carp-cluck-bug.t,v 1.6 2016/10/03 04:59:49 dpchrist Exp $ # Copyright (C) 2016 by David Paul Christensen dpchrist@holgerdanske.com # This program is free software; you can redistribute it and/or modify # it under the same terms as Perl itself. use strict; use warnings; use Carp qw( cluck ); use Test::More; use Test::Output; stderr_like( sub { cluck 'hello, world!' }, qr/hello. world/, "should pass" ); TODO: { $TODO = "false positive when Carp::cluck() called"; stderr_like( sub { cluck 'hello, world!' }, qr/goodbye/, "should not pass" ); }; done_testing; 2016-10-02 21:59:56 dpchrist@t7400 ~/sandbox/perl $ perl -c Test-Output-stderr_like-Carp-cluck-bug.t Test-Output-stderr_like-Carp-cluck-bug.t syntax OK 2016-10-02 21:59:59 dpchrist@t7400 ~/sandbox/perl $ perl Test-Output-stderr_like-Carp-cluck-bug.t ok 1 - should pass ok 2 - should not pass # TODO false positive when Carp::cluck() called 1..2
Noted. If you come up with a fix, send me a pull request!
Subject: Re: [rt.cpan.org #118235] stderr_like() gives false positive if coderef invokes Carp::cluck()
Date: Mon, 17 Oct 2016 23:31:58 -0700
To: bug-Test-Output [...] rt.cpan.org
From: David Christensen <dpchrist [...] holgerdanske.com>
Thank you for the reply. I came up with a work-around -- Capture::Tiny. David