Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1c8a7c6

Browse filesBrowse files
thefourtheyeFishrock123
authored andcommitted
test: enhance fs-watch-recursive test
This patch - issues a TAP plugin parsable message on non darwin/windows boxes - uses `const` wherever applicable - moves the test to parallel PR-URL: #2599 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 5ed30da commit 1c8a7c6
Copy full SHA for 1c8a7c6

File tree

Expand file treeCollapse file tree

2 files changed

+43
-51
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+43
-51
lines changed
Open diff view settings
Collapse file
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
5+
if (!(process.platform === 'darwin' || common.isWindows)) {
6+
console.log('1..0 # Skipped: recursive option is darwin/windows specific');
7+
return;
8+
}
9+
10+
const assert = require('assert');
11+
const path = require('path');
12+
const fs = require('fs');
13+
14+
const testDir = common.tmpDir;
15+
const filenameOne = 'watch.txt';
16+
const testsubdirName = 'testsubdir';
17+
const testsubdir = path.join(testDir, testsubdirName);
18+
const relativePathOne = path.join('testsubdir', filenameOne);
19+
const filepathOne = path.join(testsubdir, filenameOne);
20+
21+
common.refreshTmpDir();
22+
23+
fs.mkdirSync(testsubdir, 0o700);
24+
25+
const watcher = fs.watch(testDir, {recursive: true});
26+
27+
var watcherClosed = false;
28+
watcher.on('change', function(event, filename) {
29+
assert.ok('change' === event || 'rename' === event);
30+
31+
// Ignore stale events generated by mkdir and other tests
32+
if (filename !== relativePathOne)
33+
return;
34+
35+
watcher.close();
36+
watcherClosed = true;
37+
});
38+
39+
fs.writeFileSync(filepathOne, 'world');
40+
41+
process.on('exit', function() {
42+
assert(watcherClosed, 'watcher Object was not closed');
43+
});
Collapse file

‎test/sequential/test-fs-watch-recursive.js‎

Copy file name to clipboardExpand all lines: test/sequential/test-fs-watch-recursive.js
-51Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.