Skip Menu |

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

Report information
The Basics
Id: 40175
Status: open
Priority: 0/
Queue: Test-Warn

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

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



Subject: Confusing report from "at X line Y" stripping.
I was testing code to make sure it carped, warned at the line it was called, so I wrote something like this: #!/usr/bin/perl -w use Test::More tests => 1; use Test::Warn; package Foo; use Carp; sub foo { carp "Stuff"; } package main; #line 17 warning_is { Foo->foo(); } "Stuff at $0 line 18"; __END__ but the test failed with perplexing output. 1..1 not ok 1 # Failed test at /Users/schwern/tmp/test.plx line 19. # found carped warning: Stuff at /Users/schwern/tmp/test.plx line 18 # expected to find warning: Stuff at /Users/schwern/tmp/test.plx line 18 # Looks like you failed 1 test of 1. Looks like the same warnings to me. The problem is warning_is() silently strips off the "at X line Y" part, but it gives no indication of that in the output leading to some confusing failures. It would be good to indicate that in some way, but I'm not sure how without obscuring the results. Alternatively, if the user passes in an expected string with an "at X line Y" on it it could assume they mean to test the exact line and do no stripping. This avoids having to hack around it with warning_like() though I'm sure this will cause some backwards compatibility issues for people who have been unknowingly taking advantage of the at/line stripping feature.
I think I have a patch that takes care of this problem at https://github.com/yanick/test-warn/tree/accept-cr Will send a pull request in a few minutes.