◐ Shell
clean mode source ↗

test: use case-insensitive path checking on Windows in fs.cpSync tests · nodejs/node@7f457f8

Original file line numberDiff line numberDiff line change

@@ -26,12 +26,9 @@ test-async-context-frame: PASS, FLAKY

2626

test-runner-run-watch: PASS, FLAKY

2727

# https://github.com/nodejs/node/pull/59408#issuecomment-3170650933

2828

test-fs-cp-sync-error-on-exist: PASS, FLAKY

29-

test-fs-cp-sync-copy-symlink-not-pointing-to-folder: PASS, FLAKY

3029

test-fs-cp-sync-symlink-points-to-dest-error: PASS, FLAKY

31-

test-fs-cp-sync-resolve-relative-symlinks-false: PASS, FLAKY

3230

test-fs-cp-async-symlink-points-to-dest: PASS, FLAKY

3331

test-fs-cp-sync-unicode-folder-names: PASS, FLAKY

34-

test-fs-cp-sync-resolve-relative-symlinks-default: PASS, FLAKY

3532
3633

# https://github.com/nodejs/node/issues/56751

3734

test-without-async-context-frame: PASS, FLAKY

Original file line numberDiff line numberDiff line change

@@ -1,5 +1,5 @@

11

// This tests that cpSync copies link if it does not point to folder in src.

2-

import { mustNotMutateObjectDeep } from '../common/index.mjs';

2+

import { mustNotMutateObjectDeep, isWindows } from '../common/index.mjs';

33

import { nextdir } from '../common/fs.js';

44

import assert from 'node:assert';

55

import { cpSync, mkdirSync, symlinkSync, readlinkSync } from 'node:fs';

@@ -16,4 +16,11 @@ mkdirSync(join(dest, 'a'), mustNotMutateObjectDeep({ recursive: true }));

1616

symlinkSync(dest, join(dest, 'a', 'c'));

1717

cpSync(src, dest, mustNotMutateObjectDeep({ recursive: true }));

1818

const link = readlinkSync(join(dest, 'a', 'c'));

19-

assert.strictEqual(link, src);

19+
20+

if (isWindows) {

21+

// On Windows, readlinkSync() may return a path with uppercase drive letter,

22+

// but paths are case-insensitive.

23+

assert.strictEqual(link.toLowerCase(), src.toLowerCase());

24+

} else {

25+

assert.strictEqual(link, src);

26+

}

Original file line numberDiff line numberDiff line change

@@ -1,5 +1,5 @@

11

// This tests that cpSync resolves relative symlinks to their absolute path by default.

2-

import { mustNotMutateObjectDeep } from '../common/index.mjs';

2+

import { mustNotMutateObjectDeep, isWindows } from '../common/index.mjs';

33

import { nextdir } from '../common/fs.js';

44

import assert from 'node:assert';

55

import { cpSync, mkdirSync, writeFileSync, symlinkSync, readlinkSync } from 'node:fs';

@@ -18,4 +18,11 @@ mkdirSync(dest, mustNotMutateObjectDeep({ recursive: true }));

1818
1919

cpSync(src, dest, mustNotMutateObjectDeep({ recursive: true }));

2020

const link = readlinkSync(join(dest, 'bar.js'));

21-

assert.strictEqual(link, join(src, 'foo.js'));

21+
22+

if (isWindows) {

23+

// On Windows, readlinkSync() may return a path with uppercase drive letter,

24+

// but paths are case-insensitive.

25+

assert.strictEqual(link.toLowerCase(), join(src, 'foo.js').toLowerCase());

26+

} else {

27+

assert.strictEqual(link, join(src, 'foo.js'));

28+

}

Original file line numberDiff line numberDiff line change

@@ -1,5 +1,5 @@

11

// This tests that cpSync resolves relative symlinks when verbatimSymlinks is false.

2-

import { mustNotMutateObjectDeep } from '../common/index.mjs';

2+

import { mustNotMutateObjectDeep, isWindows } from '../common/index.mjs';

33

import { nextdir } from '../common/fs.js';

44

import assert from 'node:assert';

55

import { cpSync, mkdirSync, writeFileSync, symlinkSync, readlinkSync } from 'node:fs';

@@ -18,4 +18,11 @@ mkdirSync(dest, mustNotMutateObjectDeep({ recursive: true }));

1818
1919

cpSync(src, dest, mustNotMutateObjectDeep({ recursive: true, verbatimSymlinks: false }));

2020

const link = readlinkSync(join(dest, 'bar.js'));

21-

assert.strictEqual(link, join(src, 'foo.js'));

21+
22+

if (isWindows) {

23+

// On Windows, readlinkSync() may return a path with uppercase drive letter,

24+

// but paths are case-insensitive.

25+

assert.strictEqual(link.toLowerCase(), join(src, 'foo.js').toLowerCase());

26+

} else {

27+

assert.strictEqual(link, join(src, 'foo.js'));

28+

}