mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
perf(test): cache project test inventories
This commit is contained in:
@@ -2340,14 +2340,22 @@ function splitTargetChunks(targets, chunkCount) {
|
||||
return chunks;
|
||||
}
|
||||
|
||||
let cachedBroadScriptTestTargets = null;
|
||||
let cachedBroadScriptTestTargetsCwd = null;
|
||||
|
||||
function listBroadScriptTestTargets(pattern, cwd) {
|
||||
const root = path.join(cwd, "test/scripts");
|
||||
if (!fs.existsSync(root)) {
|
||||
return [];
|
||||
if (cachedBroadScriptTestTargetsCwd !== cwd) {
|
||||
// Broad-target expansion can ask for the same process-stable checkout twice.
|
||||
// Keep one inventory so planning does not repeat the directory walk.
|
||||
cachedBroadScriptTestTargets = fs.existsSync(root)
|
||||
? listRepoFilesRecursive(root, cwd)
|
||||
.filter((file) => file.endsWith(".test.ts"))
|
||||
.toSorted((left, right) => left.localeCompare(right))
|
||||
: [];
|
||||
cachedBroadScriptTestTargetsCwd = cwd;
|
||||
}
|
||||
return listRepoFilesRecursive(root, cwd)
|
||||
.filter((file) => file.endsWith(".test.ts") && path.matchesGlob(file, pattern))
|
||||
.toSorted((left, right) => left.localeCompare(right));
|
||||
return cachedBroadScriptTestTargets.filter((file) => path.matchesGlob(file, pattern));
|
||||
}
|
||||
|
||||
function listBroadToolingScriptTestTargets(pattern, cwd) {
|
||||
@@ -2356,14 +2364,24 @@ function listBroadToolingScriptTestTargets(pattern, cwd) {
|
||||
);
|
||||
}
|
||||
|
||||
let cachedToolingFullSuiteTestTargets = null;
|
||||
let cachedToolingFullSuiteTestTargetsCwd = null;
|
||||
|
||||
function listToolingFullSuiteTestTargets(cwd) {
|
||||
return uniqueOrdered(
|
||||
if (cachedToolingFullSuiteTestTargets && cachedToolingFullSuiteTestTargetsCwd === cwd) {
|
||||
return cachedToolingFullSuiteTestTargets;
|
||||
}
|
||||
// The CLI plans against one process-stable checkout. Reuse its inventory when
|
||||
// callers compare full-suite modes instead of walking the tree for every mode.
|
||||
cachedToolingFullSuiteTestTargets = uniqueOrdered(
|
||||
[path.join(cwd, "test"), path.join(cwd, "src", "scripts")].flatMap((root) =>
|
||||
fs.existsSync(root) ? listRepoFilesRecursive(root, cwd) : [],
|
||||
),
|
||||
)
|
||||
.filter((file) => file.endsWith(".test.ts") && classifyTarget(file, cwd) === "tooling")
|
||||
.toSorted((left, right) => left.localeCompare(right));
|
||||
cachedToolingFullSuiteTestTargetsCwd = cwd;
|
||||
return cachedToolingFullSuiteTestTargets;
|
||||
}
|
||||
|
||||
function listUnitFastFullSuiteTestTargets() {
|
||||
|
||||
Reference in New Issue
Block a user