mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-10 00:11:19 +00:00
refactor(test): share channel contract file discovery
This commit is contained in:
parent
2b7d7841d2
commit
b804d20da7
1 changed files with 3 additions and 23 deletions
|
|
@ -1,29 +1,9 @@
|
|||
// Builds balanced Vitest shard plans for channel plugin contract tests.
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { existsSync, readdirSync } from "node:fs";
|
||||
import { join, relative } from "node:path";
|
||||
import { relative } from "node:path";
|
||||
import { listTrackedTestFiles } from "./list-test-files.mjs";
|
||||
|
||||
function listContractTestFiles(rootDir = "src/channels/plugins/contracts") {
|
||||
const result = spawnSync("git", ["ls-files", "--", rootDir], {
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "ignore"],
|
||||
});
|
||||
if (result.status === 0) {
|
||||
return result.stdout
|
||||
.split("\n")
|
||||
.map((line) => line.trim().replaceAll("\\", "/"))
|
||||
.filter((line) => line.endsWith(".test.ts"))
|
||||
.toSorted((a, b) => a.localeCompare(b));
|
||||
}
|
||||
|
||||
if (!existsSync(rootDir)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return readdirSync(rootDir, { withFileTypes: true })
|
||||
.filter((entry) => entry.isFile() && entry.name.endsWith(".test.ts"))
|
||||
.map((entry) => join(rootDir, entry.name).replaceAll("\\", "/"))
|
||||
.toSorted((a, b) => a.localeCompare(b));
|
||||
return listTrackedTestFiles(rootDir);
|
||||
}
|
||||
|
||||
const CONTRACT_FILE_WEIGHTS = new Map([
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue