summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas R <atoomic@cpan.org>2017-11-13 16:40:31 -0600
committerNicolas R <atoomic@cpan.org>2017-11-13 21:17:27 -0600
commitcd2a978d2293dbb03a031e76b83063ff03d6a04b (patch)
tree6fec75b0c8c103bda99aab3c6e9a966dc82ccfd3
parent71aef03063d8a31440de0007b74be1e03f6cb450 (diff)
downloadperl-cd2a978d2293dbb03a031e76b83063ff03d6a04b.tar.gz
Time::HiRes disable a flapping test for CI
When running this test under heavy load we cannot assume the delta between two system calls... even when using a (nano)sleep Most Continuous Integration system will fail on this test at one point or the other.
-rw-r--r--PACKAGING11
-rw-r--r--dist/Time-HiRes/t/nanosleep.t8
2 files changed, 16 insertions, 3 deletions
diff --git a/PACKAGING b/PACKAGING
index 9b27d07a82..a603f6c5e3 100644
--- a/PACKAGING
+++ b/PACKAGING
@@ -36,4 +36,15 @@ standalone Perl script.
perl -x patchlevel.h "This is a custom patch"
+=head1 Disabling known flapping tests
+
+Some tests could fail under heavy load, whereas in most cases
+they would simply succeed. Usually, continuous integration systems
+will at one point or the other reach that problem.
+
+To disable these known tests, please set the environment
+variable CI to true.
+
+ CI=true
+
=cut
diff --git a/dist/Time-HiRes/t/nanosleep.t b/dist/Time-HiRes/t/nanosleep.t
index 5ea8ff7a1b..98cc8d9670 100644
--- a/dist/Time-HiRes/t/nanosleep.t
+++ b/dist/Time-HiRes/t/nanosleep.t
@@ -8,7 +8,7 @@ BEGIN {
}
}
-use Test::More tests => 3;
+use Test::More tests => 4;
BEGIN { push @INC, '.' }
use t::Watchdog;
@@ -25,12 +25,14 @@ ok $one == $two || $two == $three
or print("# slept too long, $one $two $three\n");
SKIP: {
- skip "no gettimeofday", 1 unless &Time::HiRes::d_gettimeofday;
+ skip "no gettimeofday", 2 unless &Time::HiRes::d_gettimeofday;
my $f = Time::HiRes::time();
Time::HiRes::nanosleep(500_000_000);
my $f2 = Time::HiRes::time();
my $d = $f2 - $f;
- ok $d > 0.4 && $d < 0.9 or print("# slept $d secs $f to $f2\n");
+ cmp_ok $d, '>', 0.4, "nanosleep for more than 0.4 sec";
+ skip "flapping test - more than 0.9 sec could be necessary...", 1 if $ENV{CI};
+ cmp_ok $d, '<', 0.9 or diag("# slept $d secs $f to $f2\n");
}
1;