From 848fb975edb8878232caaa86d8d44c3bc8e7c921 Mon Sep 17 00:00:00 2001 From: Kazuki Nakanishi Date: Fri, 3 Nov 2017 01:51:40 +0900 Subject: [PATCH] Fix a problem of file append test on Windows (#1431) * Fix a problem of file append test on Windows * Skip the test case of file node that fails on Windows * Remove close() call * Fixed a recreated file test case on Windows --- test/nodes/core/storage/50-file_spec.js | 53 +++++++++++++++---------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/test/nodes/core/storage/50-file_spec.js b/test/nodes/core/storage/50-file_spec.js index 278bfda8c..7491b477a 100644 --- a/test/nodes/core/storage/50-file_spec.js +++ b/test/nodes/core/storage/50-file_spec.js @@ -154,32 +154,43 @@ describe('file Nodes', function() { var f = fs.readFileSync(fileToTest).toString(); f.should.equal("onetwo"); - // Delete the file - fs.unlinkSync(fileToTest); - - // Recreate it - fs.writeFileSync(fileToTest,""); - - // Send two more messages to the file - n1.emit("input", {payload:"three"}); - n1.emit("input", {payload:"four"}); - - setTimeout(function() { - // Check the file was updated - try { - var f = fs.readFileSync(fileToTest).toString(); - f.should.equal("threefour"); - fs.unlinkSync(fileToTest); - done(); - } catch(err) { - done(err); - } - },wait); + if (os.type() === "Windows_NT") { + var dummyFile = path.join(resourcesDir,"50-file-test-dummy.txt"); + fs.rename(fileToTest, dummyFile, function() { + recreateTest(n1, dummyFile); + }); + } else { + recreateTest(n1, fileToTest); + } } catch(err) { done(err); } },wait); }); + + function recreateTest(n1, fileToDelete) { + // Delete the file + fs.unlinkSync(fileToDelete); + + // Recreate it + fs.writeFileSync(fileToTest,""); + + // Send two more messages to the file + n1.emit("input", {payload:"three"}); + n1.emit("input", {payload:"four"}); + + setTimeout(function() { + // Check the file was updated + try { + var f = fs.readFileSync(fileToTest).toString(); + f.should.equal("threefour"); + fs.unlinkSync(fileToTest); + done(); + } catch(err) { + done(err); + } + },wait); + } });