Skip Menu |
 

This queue is for tickets about the CGI-FormBuilder CPAN distribution.

Report information
The Basics
Id: 81650
Status: open
Priority: 0/
Queue: CGI-FormBuilder

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

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



Subject: Test failures due to hash randomisation in perl 5.17.6
Download (untitled) / with headers
text/plain 565b
Since bleadperl v5.17.5-518-g7dc8663 your tests are failing frequently. That commit introduced hash key randomization and it seems at least the test t/1a-generate.t is hit by that. Find a sample fail report at: http://www.cpantesters.org/cpan/report/b8a596c4-32da-11e2-bbc7-c694a290f8f5 You can read more about the change at http://perl5.git.perl.org/perl.git/commit/7dc8663964c66a698d31bbdc8e8abed69bddeec3 or at http://www.perlmonks.org/?node_id=1005122 You may have to run the test several times until the randomization causes a fail. HTH&&Thanks&&Regards,
Download (untitled) / with headers
text/plain 227b
На 02 дек. 2012, нд 19:29:39, ANDK написа: Show quoted text
> Since bleadperl v5.17.5-518-g7dc8663 your tests are failing > frequently.
Attached is a patch that fixes hash walks in tests, fixing the build failures. Cheers, dam
Subject: perl5.18-hashes.patch
Description: tests fail due to Perl 5.18 hash randomization With this patch the hashes are walked in alphabetic order during tests, avoiding the failures. . This is not flagged forwarded, since RT is not used by upstream, and upstream mailing list is a google group. Hopefuly others will look at RT. Author: Damyan Ivanov <dmn@debian.org> Forderded: no --- a/t/2c-template-tt2.t +++ b/t/2c-template-tt2.t @@ -114,7 +114,8 @@ for (@test) { ); # the ${mod} key twiddles fields - while(my($f,$o) = each %{$_->{mod} || {}}) { + for my $f ( sort keys %{$_->{mod} || {}} ) { + my $o = $_->{mod}{$f}; $o->{name} = $f; $form->field(%$o); } --- a/t/1a-generate.t +++ b/t/1a-generate.t @@ -579,7 +579,8 @@ for (@test) { ); # the ${mod} key twiddles fields - while(my($f,$o) = each %{$_->{mod} || {}}) { + for my $f ( sort keys %{$_->{mod} || {}} ) { + my $o = $_->{mod}{$f}; $o->{name} = $f; $form->field(%$o); }

This problem seems to affect a few more tests than those listed.

 

For instance, 

 

    prove -lr t/2d-template-fast.t

 

Will randomly fail, but only if you installed CGI::FastTemplate first.

It looks like the use of:

 

while( my ( $k, $v ) = each( %hash ) ) {

    $thing->fields( $otherthing );

}

Causes issues, because "each" order is randomized as well as "keys", and the "fields" storage retains insertion order.

So attached is a patch that rewrites all use of "each" in the tests with more stable "sort keys" loops, which incidentally fixes the problem.

( Verify by replacing "sort keys" with "reverse sort keys" in 2d-template-fast.t  which will produce consistent failure instead of consistent pass ).

 

Subject: 3.09.patch
Download 3.09.patch
text/x-diff 5.5k
diff -Naur CGI-FormBuilder-3.09/t/1c-validate.t CGI-FormBuilder-3.09b/t/1c-validate.t --- CGI-FormBuilder-3.09/t/1c-validate.t 2013-11-30 00:10:36.000000000 +0000 +++ CGI-FormBuilder-3.09b/t/1c-validate.t 2016-05-11 13:10:45.680369595 +0000 @@ -174,11 +174,11 @@ for my $t (@test) { my $form = CGI::FormBuilder->new( %{ $t->{opt} }, debug => $DEBUG ); - while(my($f,$o) = each %{$t->{mod} || {}}) { - $o->{name} = $f; - $form->field(%$o); + for my $field ( sort keys %{ $t->{mod} || {} } ) { + my $object = $t->{mod}->{$field}; + $object->{name} = $field; + $form->field( %{ $object } ); } - # just try to validate ok($form->validate, $t->{pass} || 0); } diff -Naur CGI-FormBuilder-3.09/t/1d-messages.t CGI-FormBuilder-3.09b/t/1d-messages.t --- CGI-FormBuilder-3.09/t/1d-messages.t 2013-11-30 00:10:36.000000000 +0000 +++ CGI-FormBuilder-3.09b/t/1d-messages.t 2016-05-11 13:08:33.159540213 +0000 @@ -70,8 +70,9 @@ my $locale = "fb_FAKE"; my $messages = "messages.$locale"; open(M, ">$messages") || warn "Can't write $messages: $!"; -while (my($k,$v) = each %messages) { - print M join(' ', $k, ref($v) ? @$v : $v), "\n"; +for my $k ( sort keys %messages ) { + my $v = $messages{$k}; + print M join(' ', $k, ref($v) ? @$v : $v), "\n"; } close(M); @@ -123,7 +124,7 @@ # Final test set is to just make sure we have all the keys for all modules require CGI::FormBuilder::Messages::default; my %need = CGI::FormBuilder::Messages::default->messages; -my @keys = keys %need; +my @keys = sort keys %need; for my $pm (@pm) { my($lang) = $pm =~ /([a-z]+_[A-Z]+)/; my $skip = $lang ? undef : "skip: Can't get language from $pm"; diff -Naur CGI-FormBuilder-3.09/t/2a-template-html.t CGI-FormBuilder-3.09b/t/2a-template-html.t --- CGI-FormBuilder-3.09/t/2a-template-html.t 2013-11-30 00:10:36.000000000 +0000 +++ CGI-FormBuilder-3.09b/t/2a-template-html.t 2016-05-11 13:11:57.438740284 +0000 @@ -102,18 +102,19 @@ my $seq = $ARGV[0] || 1; # Cycle thru and try it out -for (@test) { +for my $test_item (@test) { my $form = CGI::FormBuilder->new( debug => $DEBUG, action => 'TEST', title => 'TEST', - %{ $_->{opt} }, + %{ $test_item->{opt} }, ); # the ${mod} key twiddles fields - while(my($f,$o) = each %{$_->{mod} || {}}) { - $o->{name} = $f; - $form->field(%$o); + for my $field ( sort keys %{ $test_item->{mod} || {} } ) { + my $object = $test_item->{mod}->{$field}; + $object->{name} = $field; + $form->field( %{ $object } ); } # diff -Naur CGI-FormBuilder-3.09/t/2b-template-text.t CGI-FormBuilder-3.09b/t/2b-template-text.t --- CGI-FormBuilder-3.09/t/2b-template-text.t 2013-11-30 00:10:36.000000000 +0000 +++ CGI-FormBuilder-3.09b/t/2b-template-text.t 2016-05-11 13:11:29.861982062 +0000 @@ -97,18 +97,19 @@ my $seq = $ARGV[0] || 1; # Cycle thru and try it out -for (@test) { +for my $test_item (@test) { my $form = CGI::FormBuilder->new( debug => $DEBUG, action => 'TEST', title => 'TEST', - %{ $_->{opt} }, + %{ $test_item->{opt} }, ); # the ${mod} key twiddles fields - while(my($f,$o) = each %{$_->{mod} || {}}) { - $o->{name} = $f; - $form->field(%$o); + for my $field ( sort keys %{ $test_item->{mod} || {} } ) { + my $object = $test_item->{mod}->{$field}; + $object->{name} = $field; + $form->field( %{ $object } ); } # diff -Naur CGI-FormBuilder-3.09/t/2d-template-fast.t CGI-FormBuilder-3.09b/t/2d-template-fast.t --- CGI-FormBuilder-3.09/t/2d-template-fast.t 2013-11-30 00:10:36.000000000 +0000 +++ CGI-FormBuilder-3.09b/t/2d-template-fast.t 2016-05-11 13:15:58.497630259 +0000 @@ -135,18 +135,19 @@ my $seq = $ARGV[0] || 1; # Cycle thru and try it out -for (@test) { +for my $test_item (@test) { my $form = CGI::FormBuilder->new( debug => $DEBUG, action => 'TEST', title => 'TEST', - %{ $_->{opt} }, + %{ $test_item->{opt} }, ); # the ${mod} key twiddles fields - while(my($f,$o) = each %{$_->{mod} || {}}) { - $o->{name} = $f; - $form->field(%$o); + for my $field ( sort keys %{ $test_item->{mod} || {} } ) { + my $object = $test_item->{mod}->{$field}; + $object->{name} = $field; + $form->field( %{ $object } ); } # diff -Naur CGI-FormBuilder-3.09/t/2e-template-ssi.t CGI-FormBuilder-3.09b/t/2e-template-ssi.t --- CGI-FormBuilder-3.09/t/2e-template-ssi.t 2013-11-30 00:10:36.000000000 +0000 +++ CGI-FormBuilder-3.09b/t/2e-template-ssi.t 2016-05-11 13:12:37.526388964 +0000 @@ -102,18 +102,19 @@ my $seq = $ARGV[0] || 1; # Cycle thru and try it out -for (@test) { +for my $test_item (@test) { my $form = CGI::FormBuilder->new( debug => $DEBUG, action => 'TEST', title => 'TEST', - %{ $_->{opt} }, + %{ $test_item->{opt} }, ); # the ${mod} key twiddles fields - while(my($f,$o) = each %{$_->{mod} || {}}) { - $o->{name} = $f; - $form->field(%$o); + for my $field ( sort keys %{ $test_item->{mod} || {} } ) { + my $object = $test_item->{mod}->{$field}; + $object->{name} = $field; + $form->field( %{ $object } ); } #


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.