mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00

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>
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
const { mustNotMutateObjectDeep } = require('.');
|
|
const { readdirSync } = require('node:fs');
|
|
const { join } = require('node:path');
|
|
const assert = require('node:assert');
|
|
const tmpdir = require('./tmpdir.js');
|
|
|
|
let dirc = 0;
|
|
function nextdir(dirname) {
|
|
return tmpdir.resolve(dirname || `copy_%${++dirc}`);
|
|
}
|
|
|
|
function assertDirEquivalent(dir1, dir2) {
|
|
const dir1Entries = [];
|
|
collectEntries(dir1, dir1Entries);
|
|
const dir2Entries = [];
|
|
collectEntries(dir2, dir2Entries);
|
|
assert.strictEqual(dir1Entries.length, dir2Entries.length);
|
|
for (const entry1 of dir1Entries) {
|
|
const entry2 = dir2Entries.find((entry) => {
|
|
return entry.name === entry1.name;
|
|
});
|
|
assert(entry2, `entry ${entry2.name} not copied`);
|
|
if (entry1.isFile()) {
|
|
assert(entry2.isFile(), `${entry2.name} was not file`);
|
|
} else if (entry1.isDirectory()) {
|
|
assert(entry2.isDirectory(), `${entry2.name} was not directory`);
|
|
} else if (entry1.isSymbolicLink()) {
|
|
assert(entry2.isSymbolicLink(), `${entry2.name} was not symlink`);
|
|
}
|
|
}
|
|
}
|
|
|
|
function collectEntries(dir, dirEntries) {
|
|
const newEntries = readdirSync(dir, mustNotMutateObjectDeep({ withFileTypes: true }));
|
|
for (const entry of newEntries) {
|
|
if (entry.isDirectory()) {
|
|
collectEntries(join(dir, entry.name), dirEntries);
|
|
}
|
|
}
|
|
dirEntries.push(...newEntries);
|
|
}
|
|
|
|
module.exports = {
|
|
nextdir,
|
|
assertDirEquivalent,
|
|
collectEntries,
|
|
};
|