From f10b86b644e2c27e70392d01174989042af22096 Mon Sep 17 00:00:00 2001 From: "David Humphrey (:humph) david.humphrey@senecacollege.ca" Date: Tue, 4 Mar 2014 15:30:46 -0500 Subject: [PATCH] Change fs.utime test to remove constant times, prefering calculated duration. Fixes #103 --- tests/spec/fs.utimes.spec.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/spec/fs.utimes.spec.js b/tests/spec/fs.utimes.spec.js index 70c6a5d..253f102 100644 --- a/tests/spec/fs.utimes.spec.js +++ b/tests/spec/fs.utimes.spec.js @@ -158,22 +158,21 @@ define(["Filer", "util"], function(Filer, util) { var fs = util.fs(); var atimeEst; var mtimeEst; - var now; fs.writeFile('/myfile', '', function (error) { if (error) throw error; + var then = Date.now(); fs.utimes('/myfile', null, null, function (error) { expect(error).not.to.exist; - now = Date.now(); - fs.stat('/myfile', function (error, stat) { expect(error).not.to.exist; // Note: testing estimation as time may differ by a couple of milliseconds // This number should be increased if tests are on slow systems - expect(now - stat.atime).to.be.below(75); - expect(now - stat.mtime).to.be.below(75); + var delta = Date.now() - then; + expect(then - stat.atime).to.be.below(delta); + expect(then - stat.mtime).to.be.below(delta); done(); }); });