Files
openclaw/test/vitest/vitest.unit-paths.mjs
Peter Steinberger 8cd092620d test: fix changed-run routing, dedupe gateway package lanes, repair force-rerun triggers (#104287)
* test: fix changed-run routing, dedupe gateway package lanes, repair force-rerun triggers

- route extensions/active-memory changed runs to their dedicated lane; add a
  generic guard that every catch-all-excluded extension root resolves to a
  dedicated config so future split lanes cannot silently skip changed tests
- exclude packages/gateway-client and packages/gateway-protocol from the unit
  lane; explicit targets now route to the gateway-client lane (was double-run)
- generate forceRerunTriggers from the test/vitest directory and resolve all
  entries absolute: Vitest matches triggers against absolute changed-file
  paths, so the old hand-maintained relative list never matched at all
- replace deprecated envFile:false with envDir:false (Vitest 4.1.9 warning)
- give scripts/test-live.mjs stall detection teeth: kill the process group and
  exit non-zero when OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS elapses quietly
- consolidate the live-docker shell target list into changed-lanes.mjs so the
  lane regex and check targets cannot drift; cover subagent-announce edits
- delete orphans: vitest.extension-clickclack.config.ts,
  vitest.full-core-unit.config.ts, scripts/test-docker-all.sh,
  scripts/test-live-acp-spawn-defaults-docker.sh

Closes #104231

* test: keep envDir literal so sharedVitestConfig satisfies Vite UserConfig

Vite 8 types envDir as string | false; the bare object literal widened false to
boolean and broke check:test-types at the defineConfig call sites.
2026-07-11 00:58:14 -07:00

109 lines
3.0 KiB
JavaScript

// Unit test routing globs and boundary/bundled-plugin exclusions.
import path from "node:path";
import { BUNDLED_PLUGIN_ROOT_DIR } from "../../scripts/lib/bundled-plugin-paths.mjs";
export const unitTestIncludePatterns = [
"src/**/*.test.ts",
"packages/**/*.test.ts",
"test/**/*.test.ts",
];
export const boundaryTestFiles = [
"src/infra/boundary-path.test.ts",
"src/infra/git-root.test.ts",
"src/infra/home-dir.test.ts",
"src/infra/openclaw-exec-env.test.ts",
"src/infra/openclaw-root.test.ts",
"src/infra/package-json.test.ts",
"src/infra/path-env.test.ts",
"src/infra/stable-node-path.test.ts",
"test/extension-import-boundaries.test.ts",
"test/extension-test-boundary.test.ts",
"test/plugin-extension-import-boundary.test.ts",
"test/web-provider-boundary.test.ts",
];
export const bundledPluginDependentUnitTestFiles = [
"src/infra/matrix-plugin-helper.test.ts",
"src/plugin-sdk/facade-runtime.test.ts",
"src/plugins/loader.test.ts",
];
export const unitTestAdditionalExcludePatterns = [
"src/gateway/**",
"packages/gateway-client/**",
"packages/gateway-protocol/**",
"src/hooks/**",
"src/infra/**",
`${BUNDLED_PLUGIN_ROOT_DIR}/**`,
"src/browser/**",
"src/line/**",
"src/agents/**",
"src/auto-reply/**",
"src/channels/**",
"src/cli/**",
"src/commands/**",
"src/config/**",
"src/cron/**",
"src/daemon/**",
"src/media/**",
"src/plugin-sdk/**",
"src/plugins/**",
"src/process/**",
"src/secrets/**",
"src/shared/**",
"src/tasks/**",
"src/media-understanding/**",
"src/logging/**",
"src/tui/**",
"src/utils/**",
"src/wizard/**",
"src/plugins/contracts/**",
"src/scripts/**",
"src/infra/boundary-path.test.ts",
"src/infra/git-root.test.ts",
"src/infra/home-dir.test.ts",
"src/infra/openclaw-exec-env.test.ts",
"src/infra/openclaw-root.test.ts",
"src/infra/package-json.test.ts",
"src/infra/path-env.test.ts",
"src/infra/stable-node-path.test.ts",
...bundledPluginDependentUnitTestFiles,
"src/config/doc-baseline.integration.test.ts",
"src/config/schema.base.generated.test.ts",
"src/config/schema.help.quality.test.ts",
"test/**",
];
const sharedBaseExcludePatterns = [
"dist/**",
"apps/macos/**",
"apps/macos/.build/**",
"**/node_modules/**",
"**/vendor/**",
"dist/OpenClaw.app/**",
"**/*.live.test.ts",
"**/*.e2e.test.ts",
];
const normalizeRepoPath = (value) => value.split(path.sep).join("/");
const matchesAny = (file, patterns) => patterns.some((pattern) => path.matchesGlob(file, pattern));
export function isUnitConfigTestFile(file) {
const normalizedFile = normalizeRepoPath(file);
return (
matchesAny(normalizedFile, unitTestIncludePatterns) &&
!matchesAny(normalizedFile, sharedBaseExcludePatterns) &&
!matchesAny(normalizedFile, unitTestAdditionalExcludePatterns)
);
}
export function isBundledPluginDependentUnitTestFile(file) {
return bundledPluginDependentUnitTestFiles.includes(normalizeRepoPath(file));
}
export function isBoundaryTestFile(file) {
return boundaryTestFiles.includes(normalizeRepoPath(file));
}