2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2013-11-05 08:23:58 +01:00
|
|
|
var common = require('../common');
|
|
|
|
var path = require('path');
|
|
|
|
var fs = require('fs');
|
|
|
|
|
|
|
|
var testDir = common.tmpDir;
|
|
|
|
var testsubdir = path.join(testDir, 'testsubdir');
|
|
|
|
var filepath = path.join(testsubdir, 'watch.txt');
|
|
|
|
|
|
|
|
function cleanup() {
|
|
|
|
try { fs.unlinkSync(filepath); } catch (e) { }
|
|
|
|
try { fs.rmdirSync(testsubdir); } catch (e) { }
|
|
|
|
}
|
|
|
|
process.on('exit', cleanup);
|
|
|
|
cleanup();
|
|
|
|
|
2015-05-19 13:00:06 +02:00
|
|
|
try { fs.mkdirSync(testsubdir, 0o700); } catch (e) {}
|
2013-11-05 08:23:58 +01:00
|
|
|
|
|
|
|
// Need a grace period, else the mkdirSync() above fires off an event.
|
|
|
|
setTimeout(function() {
|
2015-10-20 20:40:54 +02:00
|
|
|
var watcher = fs.watch(testDir, { persistent: true }, common.fail);
|
2013-11-05 08:23:58 +01:00
|
|
|
setTimeout(function() {
|
|
|
|
fs.writeFileSync(filepath, 'test');
|
|
|
|
}, 100);
|
|
|
|
setTimeout(function() {
|
|
|
|
watcher.close();
|
|
|
|
}, 500);
|
|
|
|
}, 50);
|