From f548aeca987d23cf2002370a3bb78973830ff800 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Tue, 27 Feb 2018 14:58:18 +0000 Subject: 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. --- ext/File-Glob/t/rt131211.t | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'ext') 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"); -- cgit v1.2.1