34484a
From b4d257e2d408f0f1c6686dcdc112f3ebfec68f44 Mon Sep 17 00:00:00 2001
34484a
From: Yves Orton <demerphq@gmail.com>
34484a
Date: Tue, 27 Jun 2017 10:22:23 +0200
34484a
Subject: [PATCH] File::Glob - tweak rt131211.t to be less sensitive on wonky
34484a
 boxes
34484a
MIME-Version: 1.0
34484a
Content-Type: text/plain; charset=UTF-8
34484a
Content-Transfer-Encoding: 8bit
34484a
34484a
make the test less senstive and avoid divide by zero errors,
34484a
also we skip the test if either elapsed_match or elapsed_fail is
34484a
true, as we can not rely on the timings then. For the operations
34484a
we are doing we should get a non-zero timing from Time::HiRes.
34484a
34484a
This should mean that running this test on boxes with heavy
34484a
load, etc, will no longer result in false positives.
34484a
34484a
Signed-off-by: Petr Písař <ppisar@redhat.com>
34484a
---
34484a
 ext/File-Glob/t/rt131211.t | 9 +++++++--
34484a
 1 file changed, 7 insertions(+), 2 deletions(-)
34484a
34484a
diff --git a/ext/File-Glob/t/rt131211.t b/ext/File-Glob/t/rt131211.t
34484a
index c1bcbe0..b29cd04 100644
34484a
--- a/ext/File-Glob/t/rt131211.t
34484a
+++ b/ext/File-Glob/t/rt131211.t
34484a
@@ -49,8 +49,13 @@ while (++$count < 10) {
34484a
 is $count,10,
34484a
     "tried all the patterns without bailing out";
34484a
 
34484a
-cmp_ok $elapsed_fail/$elapsed_match,"<",2,
34484a
-    "time to fail less than twice the time to match";
34484a
+SKIP: {
34484a
+    skip "unstable timing", 1 unless $elapsed_match && $elapsed_fail;
34484a
+    ok $elapsed_fail <= 10 * $elapsed_match,
34484a
+        "time to fail less than 10x the time to match"
34484a
+        or diag("elapsed_match=$elapsed_match elapsed_fail=$elapsed_fail");
34484a
+}
34484a
+
34484a
 is "@got_files", catfile($path, $files[0]),
34484a
     "only got the expected file for xa*..b";
34484a
 is "@no_files", "", "shouldnt have files for xa*..c";
34484a
-- 
34484a
2.9.4
34484a