Skip Menu |
 

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

Report information
The Basics
Id: 87017
Status: new
Priority: 0/
Queue: Test-Unit

People
Owner: Nobody in particular
Requestors: ppisar [...] redhat.com
Cc:
AdminCc:

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

Attachments
0001-Accept-all-family-differences-in-the-AssertTest-test.patch



Subject: t/assert.t fails with perl 5.18
Download (untitled) / with headers
text/plain 509b
0.25 as well as 0.25_1325 fails t/assert.t with perl-5.18 randomly (output for 0.25_1325): not ok ERROR test_assert_deep_equals t/tlib/AssertTest.pm:573 - test_assert_deep_equals(Class::Inner::__A24) Expected Test::Unit::Failure `(?^mx:^Structures\ begin\ differing\ at: $ \n \S*\s* \$a .* = .* (?-x:HASH) .* $ \n \S*\s* \$b .* = .* (?-x:not exist))', got `Structures begin differing at: $a->{john}{spouse}{spouse}{name} = 'John Doe' $b->{john}{spouse}{spouse}{name} = 'Baby Doll' '
From: ppisar [...] redhat.com
Download (untitled) / with headers
text/plain 780b
Dne Čt 18.čec.2013 12:29:19, ppisar napsal(a): Show quoted text
> 0.25 as well as 0.25_1325 fails t/assert.t with perl-5.18 randomly > (output for 0.25_1325): > > not ok ERROR test_assert_deep_equals > t/tlib/AssertTest.pm:573 - > test_assert_deep_equals(Class::Inner::__A24) > Expected Test::Unit::Failure `(?^mx:^Structures\ begin\ differing\ at: > $ \n > \S*\s* \$a .* = .* (?-x:HASH) .* $ \n > \S*\s* \$b .* = .* (?-x:not exist))', got `Structures begin > differing at: > $a->{john}{spouse}{spouse}{name} = 'John Doe' > $b->{john}{spouse}{spouse}{name} = 'Baby Doll' > '
The test's author expects this failure, t/tlib/AssertTest.pm:484: $differ->( 'HASH', 'not exist') => [$families{orig}, $families{bad_copy}], # test may be fragile due to recursion ordering?
From: ppisar [...] redhat.com
Download (untitled) / with headers
text/plain 2.4k
Dne Čt 18.čec.2013 12:29:19, ppisar napsal(a): Show quoted text
> 0.25 as well as 0.25_1325 fails t/assert.t with perl-5.18 randomly > (output for 0.25_1325): > > not ok ERROR test_assert_deep_equals > t/tlib/AssertTest.pm:573 - > test_assert_deep_equals(Class::Inner::__A24) > Expected Test::Unit::Failure `(?^mx:^Structures\ begin\ differing\ at: > $ \n > \S*\s* \$a .* = .* (?-x:HASH) .* $ \n > \S*\s* \$b .* = .* (?-x:not exist))', got `Structures begin > differing at: > $a->{john}{spouse}{spouse}{name} = 'John Doe' > $b->{john}{spouse}{spouse}{name} = 'Baby Doll' > '
The test can be isolated (renames to AssertTest2): package AssertTest2; use strict; use ExceptionChecker; use Test::Unit::TestCase; use vars qw/@ISA/; @ISA = qw(Test::Unit::TestCase ExceptionChecker); sub test_assert_deep_equals { my $self = shift; my %families; # key=test-purpose, value=assorted circular structures foreach my $key (qw(orig bad_copy)) { my %family = ( john => { name => 'John Doe', spouse => undef, children => [], }, jane => { name => 'Jane Doe', spouse => undef, children => [], }, baby => { name => 'Baby Doll', # spouse => undef, children => [], }, ); $family{john}{spouse} = $family{jane}; $family{jane}{spouse} = $family{john}; push @{$family{john}{children}}, $family{baby}; push @{$family{jane}{children}}, $family{baby}; $families{$key} = \%family; } $families{bad_copy}->{jane}{spouse} = $families{bad_copy}->{baby}; # was ->{john} my @tests = ( qr/^Structures\ begin\ differing\ at: $ \n \S*\s* \$a .* = .* (?-x:HASH) .* $ \n \S*\s* \$b .* = .* (?-x:not exist)/mx, [ __LINE__ + 2, sub { shift->assert_deep_equals( $families{orig}, $families{bad_copy}, # test may be fragile due to recursion ordering? ) } ] ); $self->check_failures(@tests); } 1; This looks like the regular expression does not cover all difference the assert_deep_equals() can discover. Like the one presented in the test failure.
From: ppisar [...] redhat.com
Download (untitled) / with headers
text/plain 869b
Dne Pá 20.čen.2014 08:14:42, ppisar napsal(a): Show quoted text
> Dne Čt 18.čec.2013 12:29:19, ppisar napsal(a):
> > 0.25 as well as 0.25_1325 fails t/assert.t with perl-5.18 randomly > > (output for 0.25_1325): > > > > not ok ERROR test_assert_deep_equals > > t/tlib/AssertTest.pm:573 - > > test_assert_deep_equals(Class::Inner::__A24) > > Expected Test::Unit::Failure `(?^mx:^Structures\ begin\ differing\ > > at: > > $ \n > > \S*\s* \$a .* = .* (?-x:HASH) .* $ \n > > \S*\s* \$b .* = .* (?-x:not exist))', got `Structures begin > > differing at: > > $a->{john}{spouse}{spouse}{name} = 'John Doe' > > $b->{john}{spouse}{spouse}{name} = 'Baby Doll' > > '
[...] Show quoted text
> > This looks like the regular expression does not cover all difference > the assert_deep_equals() can discover. Like the one presented in the > test failure.
Attached patch fixes it. -- Petr
Subject: 0001-Accept-all-family-differences-in-the-AssertTest-test.patch
From f34895d59eb4e8d5c266a14e0e7ecba4bf6bb35c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com> Date: Fri, 20 Jun 2014 14:33:02 +0200 Subject: [PATCH] Accept all family differences in the AssertTest test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The t/assert.t's AssertTest test failed randomly depending on order of hash key traversal: not ok ERROR test_assert_deep_equals t/tlib/AssertTest.pm:500 - test_assert_deep_equals(Class::Inner::__A20) Expected Test::Unit::Failure `(?^mx:^Structures\ begin\ differing\ at: $ \n \S*\s* \$a .* = .* (?-x:HASH) .* $ \n \S*\s* \$b .* = .* (?-x:not exist))', got `Structures begin differing at: $a->{john}{spouse}{spouse}{name} = 'John Doe' $b->{john}{spouse}{spouse}{name} = 'Baby Doll' ' This fixes the test to accept the difference in spouse's name. CPAN RT#87017 Signed-off-by: Petr Písař <ppisar@redhat.com> --- t/tlib/AssertTest.pm | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/t/tlib/AssertTest.pm b/t/tlib/AssertTest.pm index 7310874..42fa860 100644 --- a/t/tlib/AssertTest.pm +++ b/t/tlib/AssertTest.pm @@ -404,10 +404,22 @@ sub test_assert_deep_equals { ); my $differ = sub { - my ($a, $b) = @_; - qr/^Structures\ begin\ differing\ at: $ \n - \S*\s* \$a .* = .* (?-x:$a) .* $ \n - \S*\s* \$b .* = .* (?-x:$b)/mx; + my ($a, $b, $c, $d) = @_; + if (defined $d) { + qr/^Structures\ begin\ differing\ at: $ \n + (?: + \S*\s* \$a .* = .* (?-x:$a) .* $ \n + \S*\s* \$b .* = .* (?-x:$b) + | + \S*\s* \$a .* = .* (?-x:$c) .* $ \n + \S*\s* \$b .* = .* (?-x:$d) + ) + /mx, + } else { + qr/^Structures\ begin\ differing\ at: $ \n + \S*\s* \$a .* = .* (?-x:$a) .* $ \n + \S*\s* \$b .* = .* (?-x:$b)/mx; + } }; my %families; # key=test-purpose, value=assorted circular structures @@ -481,7 +493,7 @@ sub test_assert_deep_equals { }, } ], - $differ->( 'HASH', 'not exist') => [$families{orig}, $families{bad_copy}], # test may be fragile due to recursion ordering? + $differ->( 'HASH', 'not exist', 'John Doe', 'Baby Doll') => [$families{orig}, $families{bad_copy}], # test may be fragile due to recursion ordering? $differ->("'3'", "'5'") => [ [ \$H, 3 ], [ \$H2, 5 ] ], $differ->("'hello'", "'goodbye'") => [ { world => \$H }, { world => \$G } ], $differ->("'hello'", "'goodbye'") => [ [ \$H, "world" ], [ \$G, "world" ] ], -- 1.9.3


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.