node/test/parallel/test-fs-cp-async-no-errors-force-false.mjs
Joyee Cheung aac7925801
test: split test-fs-cp.js
This test previously squeezed 70+ test cases into one single file
and has been constantly crashing on Windows with exit code
3221226505 and no stack trace. As it is already marked as flaky
there is no way to understand which test case is failing and
the Windows CI was constantly orange. This patch splits the
test cases into different files so it's easier to find out
which case is exactly failing and to be skipped.

PR-URL: https://github.com/nodejs/node/pull/59408
Refs: https://github.com/nodejs/node/issues/56794
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
2025-08-10 19:35:42 +00:00

28 lines
1.1 KiB
JavaScript

// This tests that it does not throw errors when directory is copied over and force is false.
import { mustCall, mustNotMutateObjectDeep } from '../common/index.mjs';
import assert from 'node:assert';
import { cp, cpSync, lstatSync, mkdirSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import tmpdir from '../common/tmpdir.js';
import { assertDirEquivalent, nextdir } from '../common/fs.js';
tmpdir.refresh();
const src = nextdir();
mkdirSync(join(src, 'a', 'b'), mustNotMutateObjectDeep({ recursive: true }));
writeFileSync(join(src, 'README.md'), 'hello world', 'utf8');
const dest = nextdir();
cpSync(src, dest, mustNotMutateObjectDeep({ dereference: true, recursive: true }));
const initialStat = lstatSync(join(dest, 'README.md'));
cp(src, dest, {
dereference: true,
force: false,
recursive: true,
}, mustCall((err) => {
assert.strictEqual(err, null);
assertDirEquivalent(src, dest);
// File should not have been copied over, so access times will be identical:
const finalStat = lstatSync(join(dest, 'README.md'));
assert.strictEqual(finalStat.ctime.getTime(), initialStat.ctime.getTime());
}));