summaryrefslogtreecommitdiff
path: root/ext/File-Glob
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2018-02-27 14:58:18 +0000
committerDavid Mitchell <davem@iabyn.com>2018-02-27 15:12:23 +0000
commitf548aeca987d23cf2002370a3bb78973830ff800 (patch)
treece70dab5d444c6b6e04a3cf321b83af95f89602e /ext/File-Glob
parentb58c2b0d98b34cdb1e784267c831fc2feedfe199 (diff)
downloadperl-f548aeca987d23cf2002370a3bb78973830ff800.tar.gz
ext/File-Glob/t/rt131211.t: fix timing issues
This test file occasionally fails test numbers 1 and/or 2 on smokes. These two tests measure how long it takes to do a matching and non-matching glob() with a lot of "a*a*a*...." and fail if the match and non-matching times differ too much (the original bug was that non-match went exponential on number of "a*"'s). However, on good systems, the timings returned are typically sub-millisecond, so I'm guessing the occasional failures are due to (small measured noise) * 100 > (another small measured noise). So this commit avoids tests 1&2 failing unless the values measured are large enough not to be merely noise. This is just speculation on my part though - I couldn't reproduce a failure myself.
Diffstat (limited to 'ext/File-Glob')
-rw-r--r--ext/File-Glob/t/rt131211.t13
1 files changed, 10 insertions, 3 deletions
diff --git a/ext/File-Glob/t/rt131211.t b/ext/File-Glob/t/rt131211.t
index ed1b321f1d..4ac0d8729d 100644
--- a/ext/File-Glob/t/rt131211.t
+++ b/ext/File-Glob/t/rt131211.t
@@ -1,3 +1,8 @@
+# tests for RT 131211
+#
+# non-matching glob("a*a*a*...") went exponential time on number of a*'s
+
+
use strict;
use warnings;
use v5.16.0;
@@ -49,14 +54,16 @@ while (++$count < 10) {
$elapsed_fail -= time;
@no_files= glob catfile $path, "x".("a*" x $count) . "c";
$elapsed_fail += time;
- last if $elapsed_fail > $elapsed_match * 100;
+ last if $elapsed_fail > ($elapsed_match < 0.2 ? 0.2 : $elapsed_match) * 100;
}
is $count,10,
- "tried all the patterns without bailing out";
+ "tried all the patterns without bailing out"
+ or diag("elapsed_match=$elapsed_match elapsed_fail=$elapsed_fail");
SKIP: {
- skip "unstable timing", 1 unless $elapsed_match && $elapsed_fail;
+ skip "unstable or too small timing", 1 unless
+ $elapsed_match >= 0.001 && $elapsed_fail >= 0.001;
ok $elapsed_fail <= 10 * $elapsed_match,
"time to fail less than 10x the time to match"
or diag("elapsed_match=$elapsed_match elapsed_fail=$elapsed_fail");