mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-10 00:11:19 +00:00
refactor(test): remove unused vitest helper exports
This commit is contained in:
parent
9fa1252119
commit
90a7f552b1
2 changed files with 5 additions and 55 deletions
|
|
@ -143,10 +143,6 @@ export function loadPatternListFromEnv(
|
|||
return loadPatternListFile(filePath, envKey);
|
||||
}
|
||||
|
||||
export function loadPatternListFromArgv(argv: string[] = process.argv): string[] | null {
|
||||
return loadPatternListFromArgvForScope(argv);
|
||||
}
|
||||
|
||||
function loadPatternListFromArgvForScope(
|
||||
argv: string[] = process.argv,
|
||||
options: { scopedDir?: string } = {},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
// Vitest system load helper probes host load before expensive test lanes.
|
||||
import { spawnSync } from "node:child_process";
|
||||
|
||||
type EnvMap = Record<string, string | undefined>;
|
||||
|
||||
|
|
@ -9,30 +8,8 @@ export type VitestProcessStats = {
|
|||
otherVitestCpuPercent: number;
|
||||
};
|
||||
|
||||
type PsResult = {
|
||||
status: number | null;
|
||||
stdout: string;
|
||||
};
|
||||
|
||||
type DetectVitestProcessStatsOptions = {
|
||||
platform?: NodeJS.Platform;
|
||||
selfPid?: number;
|
||||
runPs?: () => PsResult;
|
||||
};
|
||||
|
||||
const EMPTY_VITEST_PROCESS_STATS: VitestProcessStats = {
|
||||
otherVitestRootCount: 0,
|
||||
otherVitestWorkerCount: 0,
|
||||
otherVitestCpuPercent: 0,
|
||||
};
|
||||
|
||||
const BOOLEAN_TRUE_VALUES = new Set(["1", "true"]);
|
||||
|
||||
function isExplicitlyEnabled(value: string | undefined): boolean {
|
||||
const normalized = value?.trim().toLowerCase();
|
||||
return normalized ? BOOLEAN_TRUE_VALUES.has(normalized) : false;
|
||||
}
|
||||
|
||||
function isVitestWorkerArgs(args: string): boolean {
|
||||
return args.includes("/vitest/dist/workers/") || args.includes("\\vitest\\dist\\workers\\");
|
||||
}
|
||||
|
|
@ -55,7 +32,11 @@ export function parseVitestProcessStats(
|
|||
psOutput: string,
|
||||
selfPid: number = process.pid,
|
||||
): VitestProcessStats {
|
||||
const stats = { ...EMPTY_VITEST_PROCESS_STATS };
|
||||
const stats: VitestProcessStats = {
|
||||
otherVitestRootCount: 0,
|
||||
otherVitestWorkerCount: 0,
|
||||
otherVitestCpuPercent: 0,
|
||||
};
|
||||
|
||||
for (const line of psOutput.split("\n")) {
|
||||
const trimmed = line.trim();
|
||||
|
|
@ -90,33 +71,6 @@ export function parseVitestProcessStats(
|
|||
return stats;
|
||||
}
|
||||
|
||||
export function detectVitestProcessStats(
|
||||
env: EnvMap = process.env,
|
||||
options: DetectVitestProcessStatsOptions = {},
|
||||
): VitestProcessStats {
|
||||
const platform = options.platform ?? process.platform;
|
||||
if (platform === "win32") {
|
||||
return { ...EMPTY_VITEST_PROCESS_STATS };
|
||||
}
|
||||
|
||||
if (isExplicitlyEnabled(env.OPENCLAW_VITEST_DISABLE_SYSTEM_THROTTLE)) {
|
||||
return { ...EMPTY_VITEST_PROCESS_STATS };
|
||||
}
|
||||
|
||||
const result =
|
||||
options.runPs?.() ??
|
||||
spawnSync("ps", ["-xao", "pid=,pcpu=,args="], {
|
||||
encoding: "utf8",
|
||||
stdio: ["ignore", "pipe", "ignore"],
|
||||
});
|
||||
|
||||
if (result.status === 0 && typeof result.stdout === "string" && result.stdout.length > 0) {
|
||||
return parseVitestProcessStats(result.stdout, options.selfPid ?? process.pid);
|
||||
}
|
||||
|
||||
return { ...EMPTY_VITEST_PROCESS_STATS };
|
||||
}
|
||||
|
||||
export function shouldPrintVitestThrottle(env: EnvMap = process.env): boolean {
|
||||
const normalized = env.OPENCLAW_VITEST_PRINT_SYSTEM_THROTTLE?.trim().toLowerCase();
|
||||
return normalized ? BOOLEAN_TRUE_VALUES.has(normalized) : false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue