]> git.kaiwu.me - njs.git/commitdiff
Test262: accept ENOTEMPTY and EEXIST in fs/rename.t.mjs
authorVadim Zhestikov <v.zhestikov@f5.com>
Wed, 29 Jul 2026 21:52:06 +0000 (14:52 -0700)
committerVadimZhestikov <108960056+VadimZhestikov@users.noreply.github.com>
Wed, 29 Jul 2026 22:56:25 +0000 (15:56 -0700)
Renaming a regular file onto an existing directory is permitted by POSIX
to fail with EISDIR, ENOTDIR, ENOTEMPTY or EEXIST, and the exact errno
depends on the kernel and filesystem.  The test only accepted ENOTDIR
and EISDIR, so it began failing on the ubuntu-26.04 CI runners whose
newer kernel returns ENOTEMPTY (or EEXIST) for this case.

Accept ENOTEMPTY and EEXIST in all three variants (sync, callback and
promise based) to make the test robust across kernels while still
rejecting genuinely unexpected errors.

test/fs/rename.t.mjs

index 104b4a5b23d8ced4588737329e05ea73dc02e1ed..ad93e25a2d3e6120dd1df8d647d41eb1a1957cfd 100644 (file)
@@ -25,7 +25,8 @@ var testSync = () => new Promise((resolve, reject) => {
 
         } catch (e) {
             if (e.syscall != 'rename'
-                || (e.code != 'ENOTDIR' && e.code != 'EISDIR'))
+                || (e.code != 'ENOTDIR' && e.code != 'EISDIR'
+                    && e.code != 'ENOTEMPTY' && e.code != 'EEXIST'))
             {
                 reject(new Error('fs.unlinkSync error 1'));
             }
@@ -56,7 +57,8 @@ var testCallback = () => new Promise((resolve, reject) => {
 
             fs.rename(fname_utf8(dname), dname, err => {
                 if (err.syscall != 'rename'
-                    || (err.code != 'ENOTDIR' && err.code != 'EISDIR'))
+                    || (err.code != 'ENOTDIR' && err.code != 'EISDIR'
+                        && err.code != 'ENOTEMPTY' && err.code != 'EEXIST'))
                 {
                     reject(new Error('fs.unlink error 2'));
                 }
@@ -84,7 +86,8 @@ let testFsp = () => Promise.resolve()
 .then(() => fsp.rename(fname_utf8(dname), dname))
 .catch(e => {
     if (e.syscall != 'rename'
-        || (e.code != 'ENOTDIR' && e.code != 'EISDIR'))
+        || (e.code != 'ENOTDIR' && e.code != 'EISDIR'
+            && e.code != 'ENOTEMPTY' && e.code != 'EEXIST'))
     {
         throw new Error('fsp.rename error 1');
     }