Skip Menu |

This queue is for tickets about the Object-Lazy CPAN distribution.

Report information
The Basics
Id: 87867
Status: resolved
Priority: 0/
Queue: Object-Lazy

People
Owner: STEFFENW [...] cpan.org
Requestors: TONYC [...] cpan.org
Cc:
AdminCc:

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



Subject: changes to Carp break Object::Lazy
Carp in blead perl attempts to produce nicer output for Carp backtraces, in the current version of blead, this causes a test failure in Object::Lazy's t/11_logger.t script: tony@mars:.../build/Object-Lazy-0.13-EoBsX_$ make test TEST_VERBOSE=1 TEST_FILES=t/11_logger.t PERL_DL_NONLAZY=1 /home/tony/perl/v5.19.2-486-gfdf5fcd/bin/perl5.19.3 "-MExtUtils::Command::MM" "-e" "test_harness(1, 'blib/lib', 'blib/arch')" t/11_logger.t t/11_logger.t .. 1..3 ok 1 - use Object::Lazy; ok 2 - test log message ok 3 - test log message ok 4 - no warnings # Looks like you planned 3 tests but ran 4. Dubious, test returned 255 (wstat 65280, 0xff00) All 3 subtests passed This is happening because the $build_object function calls confess() *before* marking the object as built, resulting in duplicate logging of the object build. The attached patch fixes this problem: tony@mars:.../build/Object-Lazy-0.13-EoBsX_$ make test TEST_VERBOSE=1 TEST_FILES=t/11_logger.t cp lib/Object/Lazy.pm blib/lib/Object/Lazy.pm Skip blib/lib/Object/Lazy/Ref.pm (unchanged) Skip blib/lib/Object/Lazy/Validate.pm (unchanged) PERL_DL_NONLAZY=1 /home/tony/perl/v5.19.2-486-gfdf5fcd/bin/perl5.19.3 "-MExtUtils::Command::MM" "-e" "test_harness(1, 'blib/lib', 'blib/arch')" t/11_logger.t t/11_logger.t .. 1..3 ok 1 - use Object::Lazy; ok 2 - test log message ok 3 - no warnings ok All tests successful. Files=1, Tests=3, 0 wallclock secs ( 0.02 usr 0.01 sys + 0.03 cusr 0.00 csys = 0.06 CPU) Result: PASS tony@mars:.../build/Object-Lazy-0.13-EoBsX_$ make test PERL_DL_NONLAZY=1 /home/tony/perl/v5.19.2-486-gfdf5fcd/bin/perl5.19.3 "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/01_use.t ............ ok t/02_method.t ......... ok t/03_can.t ............ ok t/04_isa.t ............ ok t/05_given_isa.t ...... ok t/06_DOES.t ........... ok t/07_given_DOES.t ..... ok t/08_VERSION.t ........ ok t/09_given_VERSION.t .. ok t/10_ref.t ............ ok t/11_logger.t ......... ok t/12_no_ref.t ......... ok t/13_wrapped.t ........ ok t/14_test_examples.t .. skipped: Set $ENV{AUTHOR_TESTING} to run this test. t/chars.t ............. skipped: Author test. Set $ENV{AUTHOR_TESTING} to a true value to run. t/perl_critic.t ....... skipped: Test::Perl::Critic required t/pod.t ............... skipped: Test::Pod 1.14 required for testing POD t/pod_coverage.t ...... skipped: Test::Pod::Coverage 1.04 required for testing POD coverage t/prereq_build.t ...... skipped: Author test. Set $ENV{RELEASE_TESTING} to a true value to run. All tests successful. Files=19, Tests=58, 1 wallclock secs ( 0.07 usr 0.03 sys + 0.58 cusr 0.13 csys = 0.81 CPU) Result: PASS Tony
Subject: Object-Lazy-carp.patch
diff -ur -x Makefile -x 'MYMETA.*' -x blib -x '*~' Object-Lazy-0.13-y2tEzI/lib/Object/Lazy.pm Object-Lazy-0.13-2SBphP/lib/Object/Lazy.pm --- Object-Lazy-0.13-y2tEzI/lib/Object/Lazy.pm 2012-09-26 14:27:27.000000000 +1000 +++ Object-Lazy-0.13-2SBphP/lib/Object/Lazy.pm 2013-08-13 15:32:01.000000000 +1000 @@ -28,15 +28,17 @@ my $built_object = $self->{build}->(); # don't build a second time $self->{build} = sub { return $built_object }; - if ( ! $self->{is_built} && exists $self->{logger} ) { - try { - confess('object built'); + if ( ! $self->{is_built} ) { + $self->{is_built} = 1; + if ( exists $self->{logger} ) { + try { + confess('object built'); + } + catch { + $self->{logger}->($_); + }; } - catch { - $self->{logger}->($_); - }; } - $self->{is_built} = 1; ${$self_ref} = $built_object; return $built_object;
done in version 0.14