Skip to content

test: use case-insensitive path checking on Windows in fs.cpSync tests #59475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,9 @@ test-async-context-frame: PASS, FLAKY
test-runner-run-watch: PASS, FLAKY
# https://github.com/nodejs/node/pull/59408#issuecomment-3170650933
test-fs-cp-sync-error-on-exist: PASS, FLAKY
test-fs-cp-sync-copy-symlink-not-pointing-to-folder: PASS, FLAKY
test-fs-cp-sync-symlink-points-to-dest-error: PASS, FLAKY
test-fs-cp-sync-resolve-relative-symlinks-false: PASS, FLAKY
test-fs-cp-async-symlink-points-to-dest: PASS, FLAKY
test-fs-cp-sync-unicode-folder-names: PASS, FLAKY
test-fs-cp-sync-resolve-relative-symlinks-default: PASS, FLAKY

# https://github.com/nodejs/node/issues/56751
test-without-async-context-frame: PASS, FLAKY
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This tests that cpSync copies link if it does not point to folder in src.
import { mustNotMutateObjectDeep } from '../common/index.mjs';
import { mustNotMutateObjectDeep, isWindows } from '../common/index.mjs';
import { nextdir } from '../common/fs.js';
import assert from 'node:assert';
import { cpSync, mkdirSync, symlinkSync, readlinkSync } from 'node:fs';
Expand All @@ -16,4 +16,11 @@ mkdirSync(join(dest, 'a'), mustNotMutateObjectDeep({ recursive: true }));
symlinkSync(dest, join(dest, 'a', 'c'));
cpSync(src, dest, mustNotMutateObjectDeep({ recursive: true }));
const link = readlinkSync(join(dest, 'a', 'c'));
assert.strictEqual(link, src);

if (isWindows) {
// On Windows, readlinkSync() may return a path with uppercase drive letter,
// but paths are case-insensitive.
assert.strictEqual(link.toLowerCase(), src.toLowerCase());
} else {
assert.strictEqual(link, src);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This tests that cpSync resolves relative symlinks to their absolute path by default.
import { mustNotMutateObjectDeep } from '../common/index.mjs';
import { mustNotMutateObjectDeep, isWindows } from '../common/index.mjs';
import { nextdir } from '../common/fs.js';
import assert from 'node:assert';
import { cpSync, mkdirSync, writeFileSync, symlinkSync, readlinkSync } from 'node:fs';
Expand All @@ -18,4 +18,11 @@ mkdirSync(dest, mustNotMutateObjectDeep({ recursive: true }));

cpSync(src, dest, mustNotMutateObjectDeep({ recursive: true }));
const link = readlinkSync(join(dest, 'bar.js'));
assert.strictEqual(link, join(src, 'foo.js'));

if (isWindows) {
// On Windows, readlinkSync() may return a path with uppercase drive letter,
// but paths are case-insensitive.
assert.strictEqual(link.toLowerCase(), join(src, 'foo.js').toLowerCase());
} else {
assert.strictEqual(link, join(src, 'foo.js'));
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This tests that cpSync resolves relative symlinks when verbatimSymlinks is false.
import { mustNotMutateObjectDeep } from '../common/index.mjs';
import { mustNotMutateObjectDeep, isWindows } from '../common/index.mjs';
import { nextdir } from '../common/fs.js';
import assert from 'node:assert';
import { cpSync, mkdirSync, writeFileSync, symlinkSync, readlinkSync } from 'node:fs';
Expand All @@ -18,4 +18,11 @@ mkdirSync(dest, mustNotMutateObjectDeep({ recursive: true }));

cpSync(src, dest, mustNotMutateObjectDeep({ recursive: true, verbatimSymlinks: false }));
const link = readlinkSync(join(dest, 'bar.js'));
assert.strictEqual(link, join(src, 'foo.js'));

if (isWindows) {
// On Windows, readlinkSync() may return a path with uppercase drive letter,
// but paths are case-insensitive.
assert.strictEqual(link.toLowerCase(), join(src, 'foo.js').toLowerCase());
} else {
assert.strictEqual(link, join(src, 'foo.js'));
}
Loading