Repository navigation
Conversation
…tory Add test/parallel/test-fs-cp-sync-dir-exists-error-on-exist.mjs from nodejs/node, unmodified. The file is identical to the one at tag v26.10.0 (git blob bcc9547). The test calls fs.cpSync with { recursive: true, force: false, errorOnExist: true } on a destination directory that exists and holds no colliding file. It expects ERR_FS_CP_EEXIST. The guard in onDir (src/js/internal/fs/cp-sync.ts) already gives this result. With the guard removed, the 77 other test-fs-cp-* files and test/js/node/fs/cp.test.ts still pass on linux-x64.
|
Status: ready for review. This PR adds one test file and changes nothing under How to check it:
The same file exits 0 on Node v26.10.0 and fails on Node v26.3.0, which does not have nodejs/node#64124. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: oven-sh/bun/.coderabbit.yaml Review profile: ASSERTIVE Plan: Essentials Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review. WalkthroughAdds a test that checks ChangescpSync existing-directory error test
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The added test covers the intended error case; no issue identified here prevents merging after normal checks. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
There was a problem hiding this comment.
LGTM — a single ported Node test file, no runtime changes.
What was reviewed:
- The new file matches the sibling async test (test-fs-cp-async-dir-exists-error-on-exist.mjs) line-for-line apart from cpSync/assert.throws, and the diff header's new-blob hash (bcc95476) is consistent with the claimed upstream blob.
- Traced the asserted path: with errorOnExist true the src/js/node/fs.ts:973 native fast path is skipped, so the JS walker's onDir guard at src/js/internal/fs/cp-sync.ts:455 fires and decorateSystemError leaves
.codeas ERR_FS_CP_EEXIST. - Ruled out the mixed-separator path concern on Windows: the identical construction already runs in the async sibling, and fs helpers accept it.
Extended reasoning...
The PR adds one 32-line file under test/js/node/test/parallel, a directory of vendored Node.js tests that Bun runs as scripts, and touches nothing under src/. It exercises fs.cpSync with { recursive: true, errorOnExist: true, force: false } against an existing destination directory with non-colliding contents and expects ERR_FS_CP_EEXIST. No security-sensitive surface is involved. The existing onDir guard in cp-sync.ts already produces this error and the fast-path condition in fs.ts excludes errorOnExist, so the test should pass on main while covering a guard that previously had no dedicated test; the file is structurally identical to the already-vendored async sibling, and no CODEOWNER covers the path.
Problem
mainfails whenfs.cpSyncstops rejecting an existing destination directory. The options are{ recursive: true, force: false, errorOnExist: true }.onDir(src/js/internal/fs/cp-sync.ts:455) gives the rejection. With the guard removed, the 77 vendoredtest-fs-cp-*files andtest/js/node/fs/cp.test.tsstill pass. node:fs: apply cpSync errorOnExist per entry, not to the destination directory #33416 (closed) proposed that removal.Fix
test/parallel/test-fs-cp-sync-dir-exists-error-on-exist.mjs, unmodified. The git blob isbcc95476a9f6, the same as at nodejs/node tagv26.10.0.ERR_FS_CP_EEXIST.src/. The test passes onmain. It fails withAssertionError: Missing expected exception.when the guard is removed.scripts/runner.node.ts. Also all 78test-fs-cp-*files andtest/js/node/fs/cp.test.ts.Background
force: falseanderrorOnExist: true,cpthrows when the destination exists. fs: throw on existing dir in cpSync with errorOnExist nodejs/node#64124 madecpSyncdo this for an existing directory (first release: v26.10.0). fs: port Node.js v26.3.0 fs tests and fix the gaps they surface — cp error semantics, watcher event delivery, watch ignore+AbortSignal, FileHandle pull/writer, glob port, opendir/Dir, mkdtempDisposable, rmdir-recursive end-of-life, mock.fn (+119 tests) #31830 added the same guard to Bun.test-fs-cp-sync-error-on-exist.mjscopies one tree twice, so files collide.mayCopyFilethrows the same code for each colliding file. That test passes without the directory guard.test/js/node/test/parallel/holds copies of Node's own tests. CI runs each file as a script withbun run.cp.test.ts. The upstream file won because the same file runs under Node.Notes
Results for the new file, all on linux-x64:
SHASUMS256.txt)AssertionError [ERR_ASSERTION]: Missing expected exception.cp-sync.ts:455-463removedAssertionError: Missing expected exception., exit 1bun run node:test:cpfetches from themainbranch of nodejs/node, not from a tag. The file onmainwas identical to the file atv26.10.0at fetch time. The file does not exist atv26.9.0.cpSynctakes the native fast path only whenerrorOnExistis false andforceis true (src/js/node/fs.ts:973). This test always runs the JavaScript walker, on every platform.errorOnExistoccurs incp.test.ts, in 5 vendoredtest-fs-cp-*files (the new file included), and in one helper undertest/js/node/test/common/. All of these ran against the build without the guard.test/js/node/fs/cp.test.tson the debug build: 47 pass, 5 skip (Windows only), 0 fail, with and without the guard.cpSynctakes the native path. Its diff keeps the rejection of an existing destination directory.no test proof · iteration 0 · no src or test change; test-proof not applicable