test: improve test runner help text (#55227)

* test: improve test runner help text

* test: print extension help to stdout

* test: leave extension help passthrough alone

* test: parse timing update flags in one pass
This commit is contained in:
Tak Hoffman
2026-03-26 10:34:14 -05:00
committed by GitHub
parent 471da49c59
commit 06b4a0a1f2
4 changed files with 101 additions and 13 deletions

View File

@@ -5,6 +5,28 @@ import {
} from "./lib/vitest-report-cli-utils.mjs";
import { collectVitestFileDurations } from "./test-report-utils.mjs";
if (process.argv.slice(2).includes("--help")) {
console.log(
[
"Usage: node scripts/test-hotspots.mjs [options]",
"",
"Print the slowest test files from a Vitest JSON report.",
"",
"Options:",
" --config <path> Vitest config to run when no report is supplied",
" --report <path> Reuse an existing Vitest JSON report",
" --limit <count> Number of files to print (default: 20)",
" --help Show this help text",
"",
"Examples:",
" node scripts/test-hotspots.mjs",
" node scripts/test-hotspots.mjs --config vitest.channels.config.ts --limit 10",
" node scripts/test-hotspots.mjs --report /tmp/vitest-report.json",
].join("\n"),
);
process.exit(0);
}
const opts = parseVitestReportArgs(process.argv.slice(2), {
config: "vitest.unit.config.ts",
limit: 20,

View File

@@ -111,14 +111,27 @@ if (rawCli.showHelp) {
[
"Usage: node scripts/test-parallel.mjs [wrapper flags] [-- vitest args]",
"",
"Runs the planner-backed OpenClaw test wrapper.",
"",
"Wrapper flags:",
" --plan Print the resolved execution plan",
" --ci-manifest Print the planner-backed CI execution manifest as JSON",
" --explain <file> Explain how a file is classified and run",
" --surface <name> Select a surface (repeatable or comma-separated)",
" --files <pattern> Add targeted files/patterns (repeatable)",
" --plan Print the resolved execution plan and exit",
" --ci-manifest Print the planner-backed CI execution manifest as JSON and exit",
" --explain <file> Explain how a file is classified and run, then exit",
" --surface <name> Select a surface: unit, extensions, channels, gateway",
" --files <pattern> Add targeted files or path patterns (repeatable)",
" --mode <ci|local> Override runtime mode",
" --profile <name> Override execution intent (normal|max|serial)",
" --profile <name> Override execution intent: normal, max, serial",
" --help Show this help text",
"",
"Examples:",
" node scripts/test-parallel.mjs",
" node scripts/test-parallel.mjs --plan --surface unit --surface extensions",
" node scripts/test-parallel.mjs --explain src/auto-reply/reply/followup-runner.test.ts",
" node scripts/test-parallel.mjs --files src/foo.test.ts -- --reporter=dot",
"",
"Environment:",
" OPENCLAW_TEST_LIST_LANES=1 Print the resolved plan before execution",
" OPENCLAW_TEST_SHOW_POOL_DECISION=1 Include thread/fork pool decisions in diagnostics",
].join("\n"),
);
process.exit(0);

View File

@@ -6,6 +6,31 @@ import { normalizeTrackedRepoPath, tryReadJsonFile, writeJsonFile } from "./test
import { unitMemoryHotspotManifestPath } from "./test-runner-manifest.mjs";
import { matchesHotspotSummaryLane } from "./test-update-memory-hotspots-utils.mjs";
if (process.argv.slice(2).includes("--help")) {
console.log(
[
"Usage: node scripts/test-update-memory-hotspots.mjs [options]",
"",
"Generate or refresh the unit memory-hotspot manifest from test-parallel memory logs.",
"",
"Options:",
" --config <path> Vitest config label stored in the output manifest",
" --out <path> Output manifest path (default: test/fixtures/test-memory-hotspots.unit.json)",
" --lane <name> Primary lane name to match (default: unit-fast)",
" --lane-prefix <prefix> Additional lane prefixes to include (repeatable)",
" --log <path> Memory trace log to ingest (repeatable, required)",
" --min-delta-kb <kb> Minimum RSS delta to retain (default: 262144)",
" --limit <count> Max hotspot entries to retain (default: 64)",
" --help Show this help text",
"",
"Examples:",
" node scripts/test-update-memory-hotspots.mjs --log /tmp/unit-fast.log",
" node scripts/test-update-memory-hotspots.mjs --log a.log --log b.log --lane-prefix unit-fast-batch-",
].join("\n"),
);
process.exit(0);
}
function parseArgs(argv) {
return parseFlagArgs(
argv,

View File

@@ -1,5 +1,5 @@
import { intFlag, parseFlagArgs, stringFlag } from "./lib/arg-utils.mjs";
import { loadVitestReportFromArgs, parseVitestReportArgs } from "./lib/vitest-report-cli-utils.mjs";
import { loadVitestReportFromArgs } from "./lib/vitest-report-cli-utils.mjs";
import {
collectVitestFileDurations,
normalizeTrackedRepoPath,
@@ -7,19 +7,47 @@ import {
} from "./test-report-utils.mjs";
import { unitTimingManifestPath } from "./test-runner-manifest.mjs";
if (process.argv.slice(2).includes("--help")) {
console.log(
[
"Usage: node scripts/test-update-timings.mjs [options]",
"",
"Generate or refresh the unit test timing manifest from a Vitest JSON report.",
"",
"Options:",
" --config <path> Vitest config to run when no report is supplied",
" --report <path> Reuse an existing Vitest JSON report",
" --out <path> Output manifest path (default: test/fixtures/test-timings.unit.json)",
" --limit <count> Max number of file timings to retain (default: 256)",
" --default-duration-ms <ms> Fallback duration for unknown files (default: 250)",
" --help Show this help text",
"",
"Examples:",
" node scripts/test-update-timings.mjs",
" node scripts/test-update-timings.mjs --config vitest.unit.config.ts --limit 128",
" node scripts/test-update-timings.mjs --report /tmp/vitest-report.json --out /tmp/timings.json",
].join("\n"),
);
process.exit(0);
}
function parseArgs(argv) {
return parseFlagArgs(
argv,
{
...parseVitestReportArgs(argv, {
config: "vitest.unit.config.ts",
limit: 256,
reportPath: "",
}),
config: "vitest.unit.config.ts",
limit: 256,
reportPath: "",
out: unitTimingManifestPath,
defaultDurationMs: 250,
},
[stringFlag("--out", "out"), intFlag("--default-duration-ms", "defaultDurationMs", { min: 1 })],
[
stringFlag("--config", "config"),
intFlag("--limit", "limit", { min: 1 }),
stringFlag("--report", "reportPath"),
stringFlag("--out", "out"),
intFlag("--default-duration-ms", "defaultDurationMs", { min: 1 }),
],
);
}