fix(ci): avoid Windows shell arg overflow in unit-fast

This commit is contained in:
Shakker
2026-03-20 04:48:24 +00:00
committed by Shakker
parent 3db2cfef07
commit 829beced04
3 changed files with 112 additions and 3 deletions

View File

@@ -1,3 +1,4 @@
import fs from "node:fs";
import { defineConfig } from "vitest/config";
import baseConfig from "./vitest.config.ts";
import {
@@ -8,12 +9,33 @@ import {
const base = baseConfig as unknown as Record<string, unknown>;
const baseTest = (baseConfig as { test?: { include?: string[]; exclude?: string[] } }).test ?? {};
const exclude = baseTest.exclude ?? [];
export function loadExtraExcludePatternsFromEnv(
env: Record<string, string | undefined> = process.env,
): string[] {
const extraExcludeFile = env.OPENCLAW_VITEST_EXTRA_EXCLUDE_FILE?.trim();
if (!extraExcludeFile) {
return [];
}
const parsed = JSON.parse(fs.readFileSync(extraExcludeFile, "utf8")) as unknown;
if (!Array.isArray(parsed)) {
throw new TypeError(
`OPENCLAW_VITEST_EXTRA_EXCLUDE_FILE must point to a JSON array: ${extraExcludeFile}`,
);
}
return parsed.filter((value): value is string => typeof value === "string" && value.length > 0);
}
export default defineConfig({
...base,
test: {
...baseTest,
include: unitTestIncludePatterns,
exclude: [...exclude, ...unitTestAdditionalExcludePatterns],
exclude: [
...new Set([
...exclude,
...unitTestAdditionalExcludePatterns,
...loadExtraExcludePatternsFromEnv(),
]),
],
},
});