diff --git a/test/parallel/test-fs-error-messages.js b/test/parallel/test-fs-error-messages.js index e47dee023c9623..cc33dad23a2223 100644 --- a/test/parallel/test-fs-error-messages.js +++ b/test/parallel/test-fs-error-messages.js @@ -45,13 +45,13 @@ fs.writeFileSync(existingFile2, 'test', 'utf-8'); const { COPYFILE_EXCL } = fs.constants; const { internalBinding } = require('internal/test/binding'); const { + UV_EACCES, UV_EBADF, UV_EEXIST, UV_EINVAL, UV_ENOENT, UV_ENOTDIR, UV_ENOTEMPTY, - UV_EPERM } = internalBinding('uv'); // Template tag function for escaping special characters in strings so that: @@ -333,10 +333,10 @@ function re(literals, ...values) { } else { // windows assert.strictEqual( err.message, - `EPERM: operation not permitted, rename '${existingDir}' -> ` + + `EACCES: permission denied, rename '${existingDir}' -> ` + `'${existingDir2}'`); - assert.strictEqual(err.errno, UV_EPERM); - assert.strictEqual(err.code, 'EPERM'); + assert.strictEqual(err.errno, UV_EACCES); + assert.strictEqual(err.code, 'EACCES'); } return true; }; diff --git a/test/parallel/test-fs-mkdir-recursive-eaccess.js b/test/parallel/test-fs-mkdir-recursive-eaccess.js index c07f8cbd1bf4e5..48b79713a795b0 100644 --- a/test/parallel/test-fs-mkdir-recursive-eaccess.js +++ b/test/parallel/test-fs-mkdir-recursive-eaccess.js @@ -23,14 +23,11 @@ const path = require('path'); let n = 0; function makeDirectoryReadOnly(dir) { - let accessErrorCode = 'EACCES'; if (common.isWindows) { - accessErrorCode = 'EPERM'; execSync(`icacls ${dir} /deny "everyone:(OI)(CI)(DE,DC,AD,WD)"`); } else { fs.chmodSync(dir, '444'); } - return accessErrorCode; } function makeDirectoryWritable(dir) { @@ -39,11 +36,11 @@ function makeDirectoryWritable(dir) { } } -// Synchronous API should return an EACCESS error with path populated. +// Synchronous API should return an EACCES error with path populated. { const dir = path.join(tmpdir.path, `mkdirp_${n++}`); fs.mkdirSync(dir); - const codeExpected = makeDirectoryReadOnly(dir); + makeDirectoryReadOnly(dir); let err = null; try { fs.mkdirSync(path.join(dir, '/foo'), { recursive: true }); @@ -52,19 +49,19 @@ function makeDirectoryWritable(dir) { } makeDirectoryWritable(dir); assert(err); - assert.strictEqual(err.code, codeExpected); + assert.strictEqual(err.code, 'EACCES'); assert(err.path); } -// Asynchronous API should return an EACCESS error with path populated. +// Asynchronous API should return an EACCES error with path populated. { const dir = path.join(tmpdir.path, `mkdirp_${n++}`); fs.mkdirSync(dir); - const codeExpected = makeDirectoryReadOnly(dir); + makeDirectoryReadOnly(dir); fs.mkdir(path.join(dir, '/bar'), { recursive: true }, (err) => { makeDirectoryWritable(dir); assert(err); - assert.strictEqual(err.code, codeExpected); + assert.strictEqual(err.code, 'EACCES'); assert(err.path); }); } diff --git a/test/parallel/test-fs-rm.js b/test/parallel/test-fs-rm.js index e0e3fd88544fff..75f54f460a3f2c 100644 --- a/test/parallel/test-fs-rm.js +++ b/test/parallel/test-fs-rm.js @@ -314,14 +314,11 @@ function removeAsync(dir) { // This test should not be run as `root` if (!common.isIBMi && (common.isWindows || process.getuid() !== 0)) { function makeDirectoryReadOnly(dir, mode) { - let accessErrorCode = 'EACCES'; if (common.isWindows) { - accessErrorCode = 'EPERM'; execSync(`icacls ${dir} /deny "everyone:(OI)(CI)(DE,DC)"`); } else { fs.chmodSync(dir, mode); } - return accessErrorCode; } function makeDirectoryWritable(dir) { @@ -342,11 +339,11 @@ function removeAsync(dir) { try { fs.mkdirSync(dirname, { recursive: true }); fs.writeFileSync(filePath, 'hello'); - const code = makeDirectoryReadOnly(dirname, 0o444); + makeDirectoryReadOnly(dirname, 0o444); assert.throws(() => { fs.rmSync(filePath, { force: true }); }, { - code, + code: 'EACCES', name: 'Error', }); } finally { @@ -364,12 +361,12 @@ function removeAsync(dir) { fs.mkdirSync(middle); fs.mkdirSync(path.join(middle, 'leaf')); // Make `middle` non-empty try { - const code = makeDirectoryReadOnly(middle, 0o555); + makeDirectoryReadOnly(middle, 0o555); try { assert.throws(() => { fs.rmSync(root, { recursive: true }); }, { - code, + code: 'EACCES', name: 'Error', }); } catch (err) {