-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
Showing
4 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
test/parallel/test-fs-rmdir-recursive-sync-warns-not-found.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const tmpdir = require('../common/tmpdir'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
tmpdir.refresh(); | ||
|
||
{ | ||
// Should warn when trying to delete a nonexistent path | ||
common.expectWarning( | ||
'DeprecationWarning', | ||
'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' + | ||
'will throw if path does not exist or is a file. Use fs.rm(path, ' + | ||
'{ recursive: true, force: true }) instead', | ||
'DEP0147' | ||
); | ||
fs.rmdirSync(path.join(tmpdir.path, 'noexist.txt'), { recursive: true }); | ||
} |
21 changes: 21 additions & 0 deletions
21
test/parallel/test-fs-rmdir-recursive-sync-warns-on-file.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const tmpdir = require('../common/tmpdir'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
tmpdir.refresh(); | ||
|
||
{ | ||
// Should warn when trying to delete a file | ||
common.expectWarning( | ||
'DeprecationWarning', | ||
'In future versions of Node.js, fs.rmdir(path, { recursive: true }) ' + | ||
'will throw if path does not exist or is a file. Use fs.rm(path, ' + | ||
'{ recursive: true, force: true }) instead', | ||
'DEP0147' | ||
); | ||
const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt'); | ||
fs.writeFileSync(filePath, ''); | ||
fs.rmdirSync(filePath, { recursive: true }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters