test: refactor test-fs-watch-non-recursive

The test was duplicating some functionality in the `tmpdir` module.

PR-URL: https://github.com/nodejs/node/pull/25386
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Rich Trott 2019-01-07 21:57:40 -08:00
parent 82f03f89b4
commit fa5af0d508

View File

@ -25,19 +25,13 @@ const path = require('path');
const fs = require('fs');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const testDir = tmpdir.path;
const testsubdir = path.join(testDir, 'testsubdir');
const filepath = path.join(testsubdir, 'watch.txt');
function cleanup() {
try { fs.unlinkSync(filepath); } catch { }
try { fs.rmdirSync(testsubdir); } catch { }
}
process.on('exit', cleanup);
cleanup();
try { fs.mkdirSync(testsubdir, 0o700); } catch {}
fs.mkdirSync(testsubdir, 0o700);
// Need a grace period, else the mkdirSync() above fires off an event.
setTimeout(function() {