[libcache-cache-perl] 01/04: Add patch from Petr Písař to fix nondeterministic test failures.

gregor herrmann gregoa at debian.org
Fri Oct 24 12:54:46 UTC 2014


This is an automated email from the git hooks/post-receive script.

gregoa pushed a commit to branch master
in repository libcache-cache-perl.

commit fc821f21af2aef9875b2ed0461de60443b1eb6fb
Author: gregor herrmann <gregoa at debian.org>
Date:   Fri Oct 24 14:27:04 2014 +0200

    Add patch from Petr Písař to fix nondeterministic test failures.
    
    Closes: #766102
---
 .../0001-Make-tests-aware-of-running-time.patch    | 147 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 2 files changed, 148 insertions(+)

diff --git a/debian/patches/0001-Make-tests-aware-of-running-time.patch b/debian/patches/0001-Make-tests-aware-of-running-time.patch
new file mode 100644
index 0000000..9e1a0c8
--- /dev/null
+++ b/debian/patches/0001-Make-tests-aware-of-running-time.patch
@@ -0,0 +1,147 @@
+Bugs-Debian: https://bugs.debian.org/766102
+Bugs: https://rt.cpan.org/Public/Bug/Display.html?id=88418
+
+From 847184c72a9e76612cd76e97b676af85202be27c Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar at redhat.com>
+Date: Thu, 26 Jun 2014 13:43:09 +0200
+Subject: [PATCH] Make tests aware of running time
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Some tests could fail if they run slower then the tested time limits
+because then caches entries expired on different place than expected. This
+patch skips such tests if the running time is not shorter than
+expected.
+
+CPAN RT#88418
+
+Signed-off-by: Petr Písař <ppisar at redhat.com>
+---
+ lib/Cache/CacheTester.pm          | 30 ++++++++++++++++++++++++------
+ lib/Cache/SizeAwareCacheTester.pm | 25 +++++++++++++++++++++----
+ 2 files changed, 45 insertions(+), 10 deletions(-)
+
+diff --git a/lib/Cache/CacheTester.pm b/lib/Cache/CacheTester.pm
+index 8f64577..1cd6f82 100644
+--- a/lib/Cache/CacheTester.pm
++++ b/lib/Cache/CacheTester.pm
+@@ -168,12 +168,18 @@ sub _test_four
+ 
+   my $value = 'Test Value';
+ 
++  my $start = time;
+   $cache->set( $key, $value, $expires_in );
+ 
+   my $fetched_value = $cache->get( $key );
+ 
+-  ( $fetched_value eq $value ) ?
+-    $self->ok( ) : $self->not_ok( '$fetched_value eq $value' );
++  if (time - $start < $expires_in) {
++    ( $fetched_value eq $value ) ?
++      $self->ok( ) : $self->not_ok( '$fetched_value eq $value' );
++  } else {
++      $self->skip( '$fetched_value eq $value (not finished in ' .
++        $expires_in . ' s)' );
++  }
+ 
+   sleep( $EXPIRES_DELAY + 1 );
+ 
+@@ -460,12 +466,18 @@ sub _test_thirteen
+ 
+   my $value = 'Test Value';
+ 
++  my $start = time;
+   $cache->set( $key, $value, $expires_in );
+ 
+   my $fetched_value = $cache->get( $key );
+ 
+-  ( $fetched_value eq $value ) ?
+-    $self->ok( ) : $self->not_ok( '$fetched_value eq $value' );
++  if (time - $start < $expires_in) {
++    ( $fetched_value eq $value ) ?
++      $self->ok( ) : $self->not_ok( '$fetched_value eq $value' );
++  } else {
++    $self->skip( '$fetched_value eq $value (not finished in ' .
++      $expires_in . ' s)' );
++  }
+ 
+   sleep( $EXPIRES_DELAY + 1 );
+ 
+@@ -525,12 +537,18 @@ sub _test_fifteen
+ 
+   my $value = 'Test Value';
+ 
++  my $start = time;
+   $cache->set( $key, $value, $expires_in );
+ 
+   my $fetched_value = $cache->get( $key );
+ 
+-  ( $fetched_value eq $value ) ?
+-    $self->ok( ) : $self->not_ok( '$fetched_value eq $value' );
++  if (time - $start < $expires_in) {
++    ( $fetched_value eq $value ) ?
++      $self->ok( ) : $self->not_ok( '$fetched_value eq $value' );
++  } else {
++      $self->skip( '$fetched_value eq $value (not finished in ' .
++        $expires_in . ' s)' );
++  }
+ 
+   sleep( $EXPIRES_DELAY + 1 );
+ 
+diff --git a/lib/Cache/SizeAwareCacheTester.pm b/lib/Cache/SizeAwareCacheTester.pm
+index 1a660f7..b2bcb79 100644
+--- a/lib/Cache/SizeAwareCacheTester.pm
++++ b/lib/Cache/SizeAwareCacheTester.pm
+@@ -110,6 +110,7 @@ sub _test_two
+ 
+   my $first_expires_in = 20;
+ 
++  my $start = time;
+   $cache->set( $first_key, $value, $first_expires_in );
+ 
+   my $first_size = $cache->size( );
+@@ -129,11 +130,17 @@ sub _test_two
+ 
+     $cache->set( $key, $value, $second_expires_in );
+   }
++  my $second_inserted = time;
+ 
+   my $second_size = $cache->size( );
+ 
+-  ( $second_size > $first_size ) ?
+-    $self->ok( ) : $self->not_ok( '$second_size > $first_size' );
++  if (time - $start < $first_expires_in ) {
++    ( $second_size > $first_size ) ?
++      $self->ok( ) : $self->not_ok( '$second_size > $first_size' );
++  } else {
++      $self->skip( '$second_size > $first_size (not finished in ' .
++      $first_expires_in . ' s)');
++  }
+ 
+   my $size_limit = $first_size;
+ 
+@@ -146,8 +153,18 @@ sub _test_two
+ 
+   my $first_value = $cache->get( $first_key );
+ 
+-  ( $first_value eq $value ) ?
+-    $self->ok( ) : $self->not_ok( '$first_value eq $value' );
++  if (time - $start >= $first_expires_in) {
++    $self->skip( '$first_value eq $value (not finished in ' .
++      $first_expires_in . ' s)');
++  } elsif ($second_inserted + $second_expires_in >=
++      $start + $first_expires_in) {
++    $self->skip( '$first_value eq $value (second key insterted to late, ' .
++     'so first key had expiration time before the second one, ' .
++     'thus the first key was removed when limit cache size');
++  } else {
++    ( $first_value eq $value ) ?
++      $self->ok( ) : $self->not_ok( '$first_value eq $value' );
++  }
+ 
+ }
+ 
+-- 
+1.9.3
+
diff --git a/debian/patches/series b/debian/patches/series
index 3175d99..d9abf2e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 use-Digest-SHA.patch
+0001-Make-tests-aware-of-running-time.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcache-cache-perl.git



More information about the Pkg-perl-cvs-commits mailing list