Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

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

Report information
The Basics
Id: 52542
Status: new
Priority: 0/
Queue: Test-Exception

People
Owner: Nobody in particular
Requestors: norbi [...] nix.hu
Cc:
AdminCc:

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



Subject: lives_and() makes $tb->diag() print to $tb->failure_handle even in TODO tests
In lives_and() the tests print their diagnostic messages even if the whole test is in a TODO block: $ cat >without-lives_and.t <<'END' use Test::More tests => 1; use Test::Exception; TODO: { local $TODO = "just testing"; is(1, 2, "some test"); } END $ prove without-lives_and.t without-lives_and.t .. ok All tests successful. Files=1, Tests=1, 1 wallclock secs ( 0.07 usr 0.00 sys + 0.07 cusr 0.00 csys = 0.14 CPU) Result: PASS $ cat >with-lives_and.t <<'END' use Test::More tests => 1; use Test::Exception; TODO: { local $TODO = "just testing"; lives_and { is(1, 2); } "some test"; } END $ prove with-lives_and.t with-lives_and.t .. 1/1 # got: '1' # expected: '2' 2.t .. ok All tests successful. Files=1, Tests=1, 1 wallclock secs ( 0.07 usr 0.00 sys + 0.06 cusr 0.00 csys = 0.13 CPU) Result: PASS See the attached patch that fixes it. (Unfortunately the new tests in t/lives_and.t do not fail with the current Test::Exception because of a Test::Builder::Tester bug - see http://code.google.com/p/test-more/issues/detail?id=57 .)
Subject: Test-Exception_lives_and-todo.diff
diff -Naur a/Test-Exception-0.27_04/lib/Test/Exception.pm b/Test-Exception-0.27_04/lib/Test/Exception.pm --- a/Test-Exception-0.27_04/lib/Test/Exception.pm 2009-09-21 22:14:56.000000000 +0200 +++ b/Test-Exception-0.27_04/lib/Test/Exception.pm 2009-12-07 19:56:07.000000000 +0100 @@ -343,12 +343,11 @@ sub lives_and (&;$) { my ( $test, $description ) = @_; { - local $Test::Builder::Level = $Test::Builder::Level + 1; my $ok = \&Test::Builder::ok; no warnings; local *Test::Builder::ok = sub { $_[2] = $description unless defined $_[2]; - $ok->(@_); + goto $ok; }; use warnings; eval { $test->() } and return 1; diff -Naur a/Test-Exception-0.27_04/t/lives_and.t b/Test-Exception-0.27_04/t/lives_and.t --- a/Test-Exception-0.27_04/t/lives_and.t 2009-09-17 23:00:42.000000000 +0200 +++ b/Test-Exception-0.27_04/t/lives_and.t 2009-12-07 20:25:07.000000000 +0100 @@ -28,4 +28,25 @@ test_out('ok 3 - The object isa Foo' ); lives_and { isa_ok( bless({}, 'Foo'), 'Foo') }; +test_out('not ok 4 - lives_and, no_exception & failure # TODO just testing'); +test_diag(" Failed (TODO) test 'lives_and, no_exception & failure'"); +test_diag(" at $filename line 39."); +test_diag(" got: '42'"); +test_diag(" expected: '24'"); +TODO: { + local $TODO = "just testing"; + + lives_and {is works(42), 24} 'lives_and, no_exception & failure'; +} + +test_out('not ok 5 - lives_and, exception # TODO just testing'); +test_diag(" Failed (TODO) test 'lives_and, exception'"); +test_diag(" at $filename line 49."); +test_diag("died: oops at $filename line 11."); +TODO: { + local $TODO = "just testing"; + + lives_and {is dies(42), 42} 'lives_and, exception'; +} + test_test('lives_and works');