From 3a3b7488b58031ec8c9cd5faa28333eb93842d4f Mon Sep 17 00:00:00 2001 From: Timothy J Fontaine Date: Mon, 24 Feb 2014 16:54:04 -0800 Subject: [PATCH] test: pummel fs-watch-file-slow handle spurious watch file will now generate an empty event when the file doesn't exist initially --- test/pummel/test-fs-watch-file-slow.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/pummel/test-fs-watch-file-slow.js b/test/pummel/test-fs-watch-file-slow.js index 4124e0b272..2e4bc10016 100644 --- a/test/pummel/test-fs-watch-file-slow.js +++ b/test/pummel/test-fs-watch-file-slow.js @@ -40,10 +40,13 @@ fs.watchFile(FILENAME, {interval:TIMEOUT - 250}, function(curr, prev) { console.log([curr, prev]); switch (++nevents) { case 1: + assert.equal(fs.existsSync(FILENAME), false); + break; case 2: + case 3: assert.equal(fs.existsSync(FILENAME), true); break; - case 3: + case 4: assert.equal(fs.existsSync(FILENAME), false); fs.unwatchFile(FILENAME); break; @@ -53,21 +56,24 @@ fs.watchFile(FILENAME, {interval:TIMEOUT - 250}, function(curr, prev) { }); process.on('exit', function() { - assert.equal(nevents, 3); + assert.equal(nevents, 4); }); setTimeout(createFile, TIMEOUT); function createFile() { + console.log('creating file'); fs.writeFileSync(FILENAME, "test"); setTimeout(touchFile, TIMEOUT); } function touchFile() { + console.log('touch file'); fs.writeFileSync(FILENAME, "test"); setTimeout(removeFile, TIMEOUT); } function removeFile() { + console.log('remove file'); fs.unlinkSync(FILENAME); }