Merge pull request #131 from humphd/issue103

Change fs.utime test to remove constant times, prefering calculated duration. Fixes #103
This commit is contained in:
Alan K 2014-03-04 16:33:23 -05:00
commit 3c9c344011
1 changed files with 4 additions and 5 deletions

View File

@ -158,22 +158,21 @@ define(["Filer", "util"], function(Filer, util) {
var fs = util.fs(); var fs = util.fs();
var atimeEst; var atimeEst;
var mtimeEst; var mtimeEst;
var now;
fs.writeFile('/myfile', '', function (error) { fs.writeFile('/myfile', '', function (error) {
if (error) throw error; if (error) throw error;
var then = Date.now();
fs.utimes('/myfile', null, null, function (error) { fs.utimes('/myfile', null, null, function (error) {
expect(error).not.to.exist; expect(error).not.to.exist;
now = Date.now();
fs.stat('/myfile', function (error, stat) { fs.stat('/myfile', function (error, stat) {
expect(error).not.to.exist; expect(error).not.to.exist;
// Note: testing estimation as time may differ by a couple of milliseconds // Note: testing estimation as time may differ by a couple of milliseconds
// This number should be increased if tests are on slow systems // This number should be increased if tests are on slow systems
expect(now - stat.atime).to.be.below(75); var delta = Date.now() - then;
expect(now - stat.mtime).to.be.below(75); expect(then - stat.atime).to.be.below(delta);
expect(then - stat.mtime).to.be.below(delta);
done(); done();
}); });
}); });