Skip to content

Commit

Permalink
make carp_once register messages not just callsite
Browse files Browse the repository at this point in the history
Add a test as well in t/106dbic_carp.t .
  • Loading branch information
rkitover authored and ribasushi committed Mar 23, 2012
1 parent 0d6c550 commit 8fda97d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ Revision history for DBIx::Class
- Cleanup of complex resultset update/delete oprations - storage
specific code moved back to ResultSet and replaced by checks
of storage capabilities
- Fixed carp_once only emitting one single warning per package
regardless of warning content

0.08196 2011-11-29 05:35 (UTC)
* Fixes
Expand Down
6 changes: 3 additions & 3 deletions lib/DBIx/Class/Carp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ sub import {
);
};

my $fired;
my $fired = {};
*{"${into}::carp_once"} = sub {
return if $fired;
$fired = 1;
return if $fired->{$_[0]};
$fired->{$_[0]} = 1;

$warn->(
__find_caller($skip_pattern, $into),
Expand Down
27 changes: 27 additions & 0 deletions t/106dbic_carp.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;
use Test::Warn;
use DBIx::Class::Carp;
use lib 't/lib';
use DBICTest;

warnings_exist {
DBIx::Class::frobnicate();
} [
qr/carp1/,
qr/carp2/,
], 'expected warnings from carp_once';

done_testing;

sub DBIx::Class::frobnicate {
DBIx::Class::branch1();
DBIx::Class::branch2();
}

sub DBIx::Class::branch1 { carp_once 'carp1' }
sub DBIx::Class::branch2 { carp_once 'carp2' }

0 comments on commit 8fda97d

Please sign in to comment.