diff --git a/test/parallel/test-fs-rmdir-recursive-sync-warns-not-found.js b/test/parallel/test-fs-rmdir-recursive-sync-warns-not-found.js deleted file mode 100644 index 449ae0b448b3532..000000000000000 --- a/test/parallel/test-fs-rmdir-recursive-sync-warns-not-found.js +++ /dev/null @@ -1,19 +0,0 @@ -'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 }); -} diff --git a/test/parallel/test-fs-rmdir-recursive-sync-warns-on-file.js b/test/parallel/test-fs-rmdir-recursive-sync-warns-on-file.js deleted file mode 100644 index 96b9875416f9620..000000000000000 --- a/test/parallel/test-fs-rmdir-recursive-sync-warns-on-file.js +++ /dev/null @@ -1,21 +0,0 @@ -'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 }); -} diff --git a/test/parallel/test-fs-rmdir-recursive-warns-not-found.js b/test/parallel/test-fs-rmdir-recursive-throws-not-found.js similarity index 89% rename from test/parallel/test-fs-rmdir-recursive-warns-not-found.js rename to test/parallel/test-fs-rmdir-recursive-throws-not-found.js index 0d4659c21db4a4b..530f561f131d334 100644 --- a/test/parallel/test-fs-rmdir-recursive-warns-not-found.js +++ b/test/parallel/test-fs-rmdir-recursive-throws-not-found.js @@ -21,9 +21,7 @@ tmpdir.refresh(); path.join(tmpdir.path, 'noexist.txt'), { recursive: true }, common.mustCall((err) => { - assert.throws(() => { throw err; }, { - code: 'ENOENT', - }); + assert.strictEqual(err.code, 'ENOENT'); }) ); } diff --git a/test/parallel/test-fs-rmdir-recursive-warns-on-file.js b/test/parallel/test-fs-rmdir-recursive-throws-on-file.js similarity index 91% rename from test/parallel/test-fs-rmdir-recursive-warns-on-file.js rename to test/parallel/test-fs-rmdir-recursive-throws-on-file.js index a02d60599ed82ca..1edcaa4a5752db9 100644 --- a/test/parallel/test-fs-rmdir-recursive-warns-on-file.js +++ b/test/parallel/test-fs-rmdir-recursive-throws-on-file.js @@ -18,9 +18,7 @@ tmpdir.refresh(); const filePath = path.join(tmpdir.path, 'rmdir-recursive.txt'); fs.writeFileSync(filePath, ''); fs.rmdir(filePath, { recursive: true }, common.mustCall((err) => { - assert.throws(() => { throw err; }, { - code: 'ENOTDIR', - }); + assert.strictEqual(err.code, 'ENOTDIR'); })); } { diff --git a/test/parallel/test-fs-rmdir-recursive.js b/test/parallel/test-fs-rmdir-recursive.js index 7375eeacb07177e..2077c5dcce3dfce 100644 --- a/test/parallel/test-fs-rmdir-recursive.js +++ b/test/parallel/test-fs-rmdir-recursive.js @@ -73,8 +73,9 @@ function removeAsync(dir) { // Recursive removal should succeed. fs.rmdir(dir, { recursive: true }, common.mustSucceed(() => { - // No error should occur if recursive and the directory does not exist. - fs.rmdir(dir, { recursive: true }, common.mustSucceed(() => { + // An error should occur if recursive and the directory does not exist. + fs.rmdir(dir, { recursive: true }, common.mustCall((err) => { + assert.strictEqual(err.code, 'ENOENT'); // Attempted removal should fail now because the directory is gone. fs.rmdir(dir, common.mustCall((err) => { assert.strictEqual(err.syscall, 'rmdir'); @@ -119,8 +120,9 @@ function removeAsync(dir) { // Recursive removal should succeed. fs.rmdirSync(dir, { recursive: true }); - // No error should occur if recursive and the directory does not exist. - fs.rmdirSync(dir, { recursive: true }); + // An error should occur if recursive and the directory does not exist. + assert.throws(() => fs.rmdirSync(dir, { recursive: true }), + { code: 'ENOENT' }); // Attempted removal should fail now because the directory is gone. assert.throws(() => fs.rmdirSync(dir), { syscall: 'rmdir' }); @@ -140,8 +142,9 @@ function removeAsync(dir) { // Recursive removal should succeed. await fs.promises.rmdir(dir, { recursive: true }); - // No error should occur if recursive and the directory does not exist. - await fs.promises.rmdir(dir, { recursive: true }); + // An error should occur if recursive and the directory does not exist. + await assert.rejects(fs.promises.rmdir(dir, { recursive: true }), + { code: 'ENOENT' }); // Attempted removal should fail now because the directory is gone. assert.rejects(fs.promises.rmdir(dir), { syscall: 'rmdir' });