1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
Origin: upstream, http://bazaar.leonerd.org.uk/perl/IO-Async/, r1044
Bug: https://rt.cpan.org/Ticket/Display.html?id=78892
Bug-Debian: http://bugs.debian.org/680790
http://bugs.debian.org/687403
Reviewed-by: gregor herrmann <gregoa@debian.org>
Applied-Upstream: yes, in bzr and since 0.51_001, except for s/1/0/ in "use constant ..."
revno 1044
From: Paul "LeoNerd" Evans <leonerd@leonerd.org.uk>
Date: Tue 2012-06-26 23:58:58 +0100
Branch-Nick: IO-Async
Subject: Allow Loops to declare for unit-test purposes that they can't
handle subsecond timers accurately, so skip the counter tests
---
lib/IO/Async/Loop.pm | 4 ++++
lib/IO/Async/LoopTests.pm | 32 ++++++++++++++++++--------------
2 files changed, 22 insertions(+), 14 deletions(-)
--- a/lib/IO/Async/Loop.pm
+++ b/lib/IO/Async/Loop.pm
@@ -16,6 +16,10 @@
# Base value but some classes might override
use constant _CAN_ON_HANGUP => 0;
+# Some Loop implementations do not accurately handle sub-second timers.
+# This only matters for unit tests
+use constant _CAN_SUBSECOND_ACCURATELY => 0;
+
use Carp;
use IO::Socket (); # empty import
--- a/lib/IO/Async/LoopTests.pm
+++ b/lib/IO/Async/LoopTests.pm
@@ -464,21 +464,25 @@
}
} 1.5, 2.5, 'loop_once(5) while waiting for timer';
- # Check that short delays are achievable in one ->loop_once call
- foreach my $delay ( 0.001, 0.01, 0.1 ) {
- my $done;
- my $count = 0;
- my $start = time;
-
- $loop->enqueue_timer( delay => $delay, code => sub { $done++ } );
-
- while( !$done ) {
- $loop->loop_once( 1 );
- $count++;
- last if time - $start > 5; # bailout
- }
+ SKIP: {
+ skip "Unable to handle sub-second timers accurately", 3 unless $loop->_CAN_SUBSECOND_ACCURATELY;
+
+ # Check that short delays are achievable in one ->loop_once call
+ foreach my $delay ( 0.001, 0.01, 0.1 ) {
+ my $done;
+ my $count = 0;
+ my $start = time;
+
+ $loop->enqueue_timer( delay => $delay, code => sub { $done++ } );
- is( $count, 1, "One ->loop_once(1) sufficient for a single $delay second timer" );
+ while( !$done ) {
+ $loop->loop_once( 1 );
+ $count++;
+ last if time - $start > 5; # bailout
+ }
+
+ is( $count, 1, "One ->loop_once(1) sufficient for a single $delay second timer" );
+ }
}
$cancelled_fired = 0;
|