mirror of
https://github.com/multipleof4/lynchmark.git
synced 2026-01-14 08:37:56 +00:00
Fix: Verify test.js existence to ignore stale directories
This commit is contained in:
@@ -48,14 +48,22 @@ const main = async () => {
|
|||||||
const models = sModel ? [sModel] : allModels;
|
const models = sModel ? [sModel] : allModels;
|
||||||
|
|
||||||
const testDirs = (await fs.readdir(TESTS, { withFileTypes: true })).filter(d => d.isDirectory()).map(d => d.name).sort();
|
const testDirs = (await fs.readdir(TESTS, { withFileTypes: true })).filter(d => d.isDirectory()).map(d => d.name).sort();
|
||||||
let targetTests = testDirs;
|
let targetTests = [];
|
||||||
|
|
||||||
if (sTest) {
|
const candidates = sTest
|
||||||
targetTests = testDirs.filter(d => d.startsWith(`${sTest}_`));
|
? testDirs.filter(d => d.startsWith(`${sTest}_`))
|
||||||
if (!targetTests.length) throw new Error(`Test ${sTest} not found.`);
|
: testDirs.slice(0, Math.ceil(testDirs.length * (pct / 100)));
|
||||||
} else {
|
|
||||||
targetTests = testDirs.slice(0, Math.ceil(testDirs.length * (pct / 100)));
|
for (const dir of candidates) {
|
||||||
|
try {
|
||||||
|
await fs.access(path.join(TESTS, dir, 'test.js'));
|
||||||
|
targetTests.push(dir);
|
||||||
|
} catch {
|
||||||
|
if (sTest) console.warn(`Skipping ${dir}: test.js not found`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sTest && !targetTests.length) throw new Error(`No valid tests found for "${sTest}"`);
|
||||||
|
|
||||||
const clean = dir => fs.rm(path.join(TESTS, dir, OUT_DIR_NAME, sModel ? `${sModel.replace(/[\/:]/g, '_')}.js` : ''), { recursive: !sModel, force: true });
|
const clean = dir => fs.rm(path.join(TESTS, dir, OUT_DIR_NAME, sModel ? `${sModel.replace(/[\/:]/g, '_')}.js` : ''), { recursive: !sModel, force: true });
|
||||||
await Promise.all(targetTests.map(clean));
|
await Promise.all(targetTests.map(clean));
|
||||||
|
|||||||
Reference in New Issue
Block a user