Skip to content

Commit 0c5e8ed

Browse files
iansutargos
authored andcommitted
test: add additional deprecation warning tests for rmdir recursive
PR-URL: #35683 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ben Coe <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 4b7708a commit 0c5e8ed

4 files changed

+41
-2
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict';
2+
const common = require('../common');
3+
const tmpdir = require('../common/tmpdir');
4+
const fs = require('fs');
5+
const path = require('path');
6+
7+
tmpdir.refresh();
8+
9+
{
10+
// Should warn when trying to delete a nonexistent path
11+
common.expectWarning(
12+
'DeprecationWarning',
13+
'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' +
14+
'will throw if path does not exist or is a file. Use fs.rm(path, ' +
15+
'{ recursive: true, force: true }) instead',
16+
'DEP0147'
17+
);
18+
fs.rmdirSync(path.join(tmpdir.path, 'noexist.txt'), { recursive: true });
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
const common = require('../common');
3+
const tmpdir = require('../common/tmpdir');
4+
const fs = require('fs');
5+
const path = require('path');
6+
7+
tmpdir.refresh();
8+
9+
{
10+
// Should warn when trying to delete a file
11+
common.expectWarning(
12+
'DeprecationWarning',
13+
'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' +
14+
'will throw if path does not exist or is a file. Use fs.rm(path, ' +
15+
'{ recursive: true, force: true }) instead',
16+
'DEP0147'
17+
);
18+
const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt');
19+
fs.writeFileSync(filePath, '');
20+
fs.rmdirSync(filePath, { recursive: true });
21+
}

test/parallel/test-fs-rmdir-recursive-warns-not-found.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const path = require('path');
66

77
tmpdir.refresh();
88

9-
109
{
1110
// Should warn when trying to delete a nonexistent path
1211
common.expectWarning(

test/parallel/test-fs-rmdir-recursive-warns-on-file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ tmpdir.refresh();
1717
);
1818
const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt');
1919
fs.writeFileSync(filePath, '');
20-
fs.rmdirSync(filePath, { recursive: true });
20+
fs.rmdir(filePath, { recursive: true }, common.mustSucceed());
2121
}

0 commit comments

Comments
 (0)