mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-10 17:16:55 +00:00
fix: shard OpenAI transport stream tests (#109181)
* test(agents): shard OpenAI transport stream suites * chore(lint): transfer transport test baselines
This commit is contained in:
committed by
GitHub
parent
0903ebe4fa
commit
05dd921016
@@ -511,13 +511,13 @@ src/agents/model-selection.test.ts
|
||||
src/agents/models.profiles.live.test.ts
|
||||
src/agents/openai-completions-transport.ts
|
||||
src/agents/openai-responses-transport.ts
|
||||
src/agents/openai-transport-stream.base.test-utils.ts
|
||||
src/agents/openai-transport-stream.deepseek-and-shaping.test-utils.ts
|
||||
src/agents/openai-transport-stream.inline-reasoning-and-tool-calls.test-utils.ts
|
||||
src/agents/openai-transport-stream.reasoning-and-cache.test-utils.ts
|
||||
src/agents/openai-transport-stream.replay-and-tools.test-utils.ts
|
||||
src/agents/openai-transport-stream.streaming.test-utils.ts
|
||||
src/agents/openai-transport-stream.usage-and-calls.test-utils.ts
|
||||
src/agents/openai-transport-stream.base.test.ts
|
||||
src/agents/openai-transport-stream.deepseek-and-shaping.test.ts
|
||||
src/agents/openai-transport-stream.inline-reasoning-and-tool-calls.test.ts
|
||||
src/agents/openai-transport-stream.reasoning-and-cache.test.ts
|
||||
src/agents/openai-transport-stream.replay-and-tools.test.ts
|
||||
src/agents/openai-transport-stream.streaming.test.ts
|
||||
src/agents/openai-transport-stream.usage-and-calls.test.ts
|
||||
src/agents/openclaw-tools.media-factory-plan.test.ts
|
||||
src/agents/openclaw-tools.session-status.test.ts
|
||||
src/agents/openclaw-tools.sessions.test.ts
|
||||
|
||||
@@ -2700,7 +2700,8 @@ function isPathLikeTargetArg(arg, cwd) {
|
||||
isGlobTarget(arg) ||
|
||||
isFileLikeTarget(arg) ||
|
||||
isVitestConfigPathLikeTarget(relative) ||
|
||||
isExistingPathTarget(arg, cwd)
|
||||
isExistingPathTarget(arg, cwd) ||
|
||||
Boolean(resolveExplicitTestPrefixTargets(arg, cwd)?.length)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2767,6 +2768,26 @@ function listExplicitTestTargetFilesForCwd(cwd) {
|
||||
return cachedExplicitTestTargetFiles;
|
||||
}
|
||||
|
||||
function resolveExplicitTestPrefixTargets(targetArg, cwd) {
|
||||
if (isExistingPathTarget(targetArg, cwd) || isGlobTarget(targetArg)) {
|
||||
return null;
|
||||
}
|
||||
const relative = toRepoRelativeTarget(targetArg, cwd).replace(/\/+$/u, "");
|
||||
if (!relative || isLikelyFileTarget(relative)) {
|
||||
return null;
|
||||
}
|
||||
const directory = path.posix.dirname(relative);
|
||||
const prefix = `${relative}.`;
|
||||
const targets = listExplicitTestTargetFilesForCwd(cwd).filter(
|
||||
(file) =>
|
||||
fs.existsSync(path.join(cwd, file)) &&
|
||||
path.posix.dirname(file) === directory &&
|
||||
file.startsWith(prefix) &&
|
||||
isTestFileTarget(file),
|
||||
);
|
||||
return targets.length > 0 ? targets.toSorted((left, right) => left.localeCompare(right)) : null;
|
||||
}
|
||||
|
||||
function includePatternMatchesAnyFile(pattern, files) {
|
||||
return files.some((file) => file === pattern || path.matchesGlob(file, pattern));
|
||||
}
|
||||
@@ -2810,6 +2831,10 @@ function expandExplicitSourceTestTargets(targetArgs, cwd) {
|
||||
const forceFullImportGraph = sourceTargetCount > EXPLICIT_SOURCE_FULL_IMPORT_GRAPH_THRESHOLD;
|
||||
return targetArgs.flatMap((targetArg) => {
|
||||
const relative = toRepoRelativeTarget(targetArg, cwd);
|
||||
const prefixTargets = resolveExplicitTestPrefixTargets(targetArg, cwd);
|
||||
if (prefixTargets) {
|
||||
return prefixTargets;
|
||||
}
|
||||
if (relative === "src/commands" && isExistingDirectoryTarget(targetArg, cwd)) {
|
||||
return [COMMANDS_LIGHT_VITEST_CONFIG, COMMANDS_VITEST_CONFIG];
|
||||
}
|
||||
@@ -2928,6 +2953,9 @@ export function findUnmatchedExplicitTestTargets(args, cwd = process.cwd()) {
|
||||
|
||||
const absolute = path.resolve(cwd, targetArg);
|
||||
if (!fs.existsSync(absolute)) {
|
||||
if (resolveExplicitTestPrefixTargets(targetArg, cwd)) {
|
||||
continue;
|
||||
}
|
||||
unmatched.push({
|
||||
target: targetArg,
|
||||
reason: "path-does-not-exist",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// Imported by openai-transport-stream.test.ts to keep its mocked suite in one Vitest module graph.
|
||||
import type { ChatCompletionChunk } from "openai/resources/chat/completions.js";
|
||||
import type { Api, Model } from "openclaw/plugin-sdk/llm";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
@@ -1,4 +1,3 @@
|
||||
// Imported by openai-transport-stream.test.ts to keep its mocked suite in one Vitest module graph.
|
||||
import { createServer } from "node:http";
|
||||
import { SYSTEM_PROMPT_CACHE_BOUNDARY } from "@openclaw/ai/internal/shared";
|
||||
import type { ChatCompletionChunk } from "openai/resources/chat/completions.js";
|
||||
@@ -1,4 +1,3 @@
|
||||
// Imported by openai-transport-stream.test.ts to keep its mocked suite in one Vitest module graph.
|
||||
import { createServer } from "node:http";
|
||||
import { expectDefined } from "@openclaw/normalization-core";
|
||||
import { describe, expect, it } from "vitest";
|
||||
@@ -1,4 +1,3 @@
|
||||
// Imported by openai-transport-stream.test.ts to keep its mocked suite in one Vitest module graph.
|
||||
import { SYSTEM_PROMPT_CACHE_BOUNDARY } from "@openclaw/ai/internal/shared";
|
||||
import { expectDefined } from "@openclaw/normalization-core";
|
||||
import type { Model } from "openclaw/plugin-sdk/llm";
|
||||
@@ -1,4 +1,3 @@
|
||||
// Imported by openai-transport-stream.test.ts to keep its mocked suite in one Vitest module graph.
|
||||
import { SYSTEM_PROMPT_CACHE_BOUNDARY } from "@openclaw/ai/internal/shared";
|
||||
import { expectDefined } from "@openclaw/normalization-core";
|
||||
import OpenAI from "openai";
|
||||
@@ -1,4 +1,3 @@
|
||||
// Imported by openai-transport-stream.test.ts to keep its mocked suite in one Vitest module graph.
|
||||
import type { Model } from "openclaw/plugin-sdk/llm";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildOpenAICompletionsParams } from "./openai-transport-stream.js";
|
||||
@@ -1,4 +1,3 @@
|
||||
// Imported by openai-transport-stream.test.ts to keep its mocked suite in one Vitest module graph.
|
||||
import { createServer } from "node:http";
|
||||
import type { Model } from "openclaw/plugin-sdk/llm";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
@@ -1,8 +0,0 @@
|
||||
import "./openai-transport-stream.base.test-utils.js";
|
||||
import "./openai-transport-stream.streaming.test-utils.js";
|
||||
import "./openai-transport-stream.deepseek-and-shaping.test-utils.js";
|
||||
import "./openai-transport-stream.replay-and-tools.test-utils.js";
|
||||
import "./openai-transport-stream.reasoning-and-cache.test-utils.js";
|
||||
import "./openai-transport-stream.usage-and-calls.test-utils.js";
|
||||
import "./openai-transport-stream.inline-reasoning-and-tool-calls.test-utils.js";
|
||||
import "./openai-transport-stream.replay-sanitization.test-utils.js";
|
||||
@@ -1,4 +1,3 @@
|
||||
// Imported by openai-transport-stream.test.ts to keep its mocked suite in one Vitest module graph.
|
||||
import type { Model } from "openclaw/plugin-sdk/llm";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { buildOpenAICompletionsParams } from "./openai-transport-stream.js";
|
||||
@@ -94,12 +94,12 @@ describe("test-projects args", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps extracted test entries in their owner configs", () => {
|
||||
expect(buildVitestRunPlans(["src/agents/openai-transport-stream.test.ts"])).toEqual([
|
||||
it("keeps split test entries in their owner configs", () => {
|
||||
expect(buildVitestRunPlans(["src/agents/openai-transport-stream.base.test.ts"])).toEqual([
|
||||
{
|
||||
config: "test/vitest/vitest.agents.config.ts",
|
||||
forwardedArgs: [],
|
||||
includePatterns: ["src/agents/openai-transport-stream.test.ts"],
|
||||
includePatterns: ["src/agents/openai-transport-stream.base.test.ts"],
|
||||
watchMode: false,
|
||||
},
|
||||
]);
|
||||
@@ -113,6 +113,26 @@ describe("test-projects args", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("expands a test filename prefix into standalone sibling suites", () => {
|
||||
expect(buildVitestRunPlans(["src/agents/openai-transport-stream"])).toEqual([
|
||||
{
|
||||
config: "test/vitest/vitest.agents.config.ts",
|
||||
forwardedArgs: [],
|
||||
includePatterns: [
|
||||
"src/agents/openai-transport-stream.base.test.ts",
|
||||
"src/agents/openai-transport-stream.deepseek-and-shaping.test.ts",
|
||||
"src/agents/openai-transport-stream.inline-reasoning-and-tool-calls.test.ts",
|
||||
"src/agents/openai-transport-stream.reasoning-and-cache.test.ts",
|
||||
"src/agents/openai-transport-stream.replay-and-tools.test.ts",
|
||||
"src/agents/openai-transport-stream.replay-sanitization.test.ts",
|
||||
"src/agents/openai-transport-stream.streaming.test.ts",
|
||||
"src/agents/openai-transport-stream.usage-and-calls.test.ts",
|
||||
],
|
||||
watchMode: false,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("routes top-level repo tests to the contracts config", () => {
|
||||
expect(buildVitestRunPlans(["test/appcast.test.ts"])).toEqual([
|
||||
{
|
||||
|
||||
@@ -197,7 +197,7 @@ describe("unit-fast vitest lane", () => {
|
||||
|
||||
it("keeps obvious stateful files out of the unit-fast lane", () => {
|
||||
expect(isUnitFastTestFile("src/plugin-sdk/temp-path.test.ts")).toBe(false);
|
||||
expect(isUnitFastTestFile("src/agents/openai-transport-stream.test.ts")).toBe(false);
|
||||
expect(isUnitFastTestFile("src/agents/openai-transport-stream.base.test.ts")).toBe(false);
|
||||
expect(isUnitFastTestFile("src/auto-reply/reply/dispatch-from-config.test.ts")).toBe(false);
|
||||
expect(isUnitFastTestFile("src/agents/sandbox.resolveSandboxContext.test.ts")).toBe(false);
|
||||
expect(isUnitFastTestFile("src/acp/runtime/session-meta.test.ts")).toBe(false);
|
||||
|
||||
@@ -221,8 +221,8 @@ const broadUnitFastCandidateGlobs = [
|
||||
"packages/**/*.test.ts",
|
||||
"test/**/*.test.ts",
|
||||
];
|
||||
const ownerRoutedUnitTestFiles = [
|
||||
"src/agents/openai-transport-stream.test.ts",
|
||||
const ownerRoutedUnitTestPatterns = [
|
||||
"src/agents/openai-transport-stream.*.test.ts",
|
||||
"src/auto-reply/reply/dispatch-from-config.test.ts",
|
||||
];
|
||||
const broadUnitFastCandidateSkipGlobs = [
|
||||
@@ -233,9 +233,8 @@ const broadUnitFastCandidateSkipGlobs = [
|
||||
// Explicit bundled ownership outranks content-based discovery. Otherwise extracting
|
||||
// a test body can silently move its entry to a config with the wrong mocked setup.
|
||||
...bundledPluginDependentUnitTestFiles,
|
||||
// These entries register tests from imported utility modules. Their tiny entry files
|
||||
// cannot carry the stateful-content signals that keep them in their owner configs.
|
||||
...ownerRoutedUnitTestFiles,
|
||||
// Keep these suites in owner configs even when content-based discovery changes.
|
||||
...ownerRoutedUnitTestPatterns,
|
||||
"src/agents/sandbox.resolveSandboxContext.test.ts",
|
||||
"src/acp/runtime/session-meta.test.ts",
|
||||
"src/channels/plugins/contracts/**/*.test.ts",
|
||||
|
||||
Reference in New Issue
Block a user