diff options
Diffstat (limited to 'test/pummel/test-watch-file.js')
-rw-r--r-- | test/pummel/test-watch-file.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/pummel/test-watch-file.js b/test/pummel/test-watch-file.js new file mode 100644 index 0000000000..1c235d6d17 --- /dev/null +++ b/test/pummel/test-watch-file.js @@ -0,0 +1,27 @@ +process.mixin(require("../common")); + +var path = require("path"); + +var f = path.join(fixturesDir, "x.txt"); +var f2 = path.join(fixturesDir, "x2.txt"); + +puts("watching for changes of " + f); + +var changes = 0; +process.watchFile(f, function (curr, prev) { + puts(f + " change"); + changes++; + assert.ok(curr.mtime != prev.mtime); + process.unwatchFile(f); +}); + + +var fs = require("fs"); + +var fd = fs.openSync(f, "w+"); +fs.writeSync(fd, 'xyz\n'); +fs.closeSync(fd); + +process.addListener("exit", function () { + assert.ok(changes > 0); +}); |