Bugzilla – Attachment 68219 Details for
Bug 19463
TestBuilder.t is failing randomly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19463: Additional changes to gen_text
Bug-19463-Additional-changes-to-gentext.patch (text/plain), 1.86 KB, created by
Marcel de Rooy
on 2017-10-17 15:02:52 UTC
(
hide
)
Description:
Bug 19463: Additional changes to gen_text
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-10-17 15:02:52 UTC
Size:
1.86 KB
patch
obsolete
>From db08cb517ee644bce9788e3271fe58171d3973dd Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 17 Oct 2017 16:57:16 +0200 >Subject: [PATCH] Bug 19463: Additional changes to gen_text >Content-Type: text/plain; charset=utf-8 > >Use Bytes::Random::Secure instead of perl rand. >Return a string from 50 to 100% of $size. >--- > t/lib/TestBuilder.pm | 27 +++++++++++++++------------ > 1 file changed, 15 insertions(+), 12 deletions(-) > >diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm >index a412846..d42372e 100644 >--- a/t/lib/TestBuilder.pm >+++ b/t/lib/TestBuilder.pm >@@ -4,6 +4,7 @@ use Modern::Perl; > > use Koha::Database; > >+use Bytes::Random::Secure; > use Carp; > use Module::Load; > use String::Random; >@@ -432,18 +433,20 @@ sub _gen_datetime { > sub _gen_text { > my ($self, $params) = @_; > # From perldoc String::Random >- # max: specify the maximum number of characters to return for * and other >- # regular expression patters that don't return a fixed number of characters >- my $regex = '[A-Za-z][A-Za-z0-9_]*'; >- my $size = $params->{info}{size}; >- if ( defined $size and $size > 1 ) { >- $size--; >- } elsif ( defined $size and $size == 1 ) { >- $regex = '[A-Za-z]'; >- } >- my $random = String::Random->new( max => $size ); >- my $text = $random->randregex($regex); >- return $text; >+ my $size = $params->{info}{size} // 10; >+ $size -= alt_rand(0.5 * $size); >+ my $regex = $size > 1 >+ ? '[A-Za-z][A-Za-z0-9_]{'.($size-1).'}' >+ : '[A-Za-z]'; >+ my $random = String::Random->new( max => $size, rand_gen => \&alt_rand ); >+ return $random->randregex($regex); >+} >+ >+sub alt_rand { #Alternative randomizer >+ my ($max) = @_; >+ my $random = Bytes::Random::Secure->new( NonBlocking => 1 ); >+ my $r = $random->irand / 2**32; >+ return int( $r * $max ); > } > > sub _gen_set_enum { >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19463
:
68217
|
68218
| 68219 |
68244