Commit 72bb834e247 for nodejs
commit 72bb834e247bd7a3c7e8b60cbcce346567e3cb48
Author: Shelley Vohr <shelley.vohr@gmail.com>
Date: Thu Sep 24 17:36:00 2026 +0200
test: accept ENOTEMPTY from libc++ in test-fs-rm
fs.rmSync() is implemented with std::filesystem::remove_all(). When a
read-only directory has a child, libc++ before LLVM 23 drops the
child's EACCES and reports the ENOTEMPTY it then gets for the parent
instead. The test pinned that behavior to macOS, but it depends on the
C++ standard library rather than on the OS: a Linux build against
libc++ fails the test when run as non-root, and macOS will start
reporting EACCES once it ships the fixed libc++. Accept either code
for that case on all POSIX platforms.
Refs: https://github.com/llvm/llvm-project/pull/197104
Refs: https://github.com/nodejs/node/pull/57103
Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66065
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
diff --git a/test/parallel/test-fs-rm.js b/test/parallel/test-fs-rm.js
index 1d0578e3004..80600d114b9 100644
--- a/test/parallel/test-fs-rm.js
+++ b/test/parallel/test-fs-rm.js
@@ -490,10 +490,9 @@ if (isGitPresent) {
// This test should not be run as `root`
if (!common.isIBMi && (common.isWindows || process.getuid() !== 0)) {
function makeDirectoryReadOnly(dir, allowExecute) {
- let accessErrorCode = 'EACCES';
- if (common.isMacOS && allowExecute) {
- accessErrorCode = 'ENOTEMPTY';
- }
+ // With libc++ before LLVM 23 remove_all() reports the parent's ENOTEMPTY
+ // over the child's EACCES: https://github.com/llvm/llvm-project/pull/197104
+ let accessErrorCode = allowExecute ? /^(EACCES|ENOTEMPTY)$/ : 'EACCES';
if (common.isWindows) {
accessErrorCode = 'EPERM';
const permissions = ['DE', 'DC'];