docs: document session shell tests · openclaw/openclaw@939fe70
steipete
·
2026-06-05
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Verifies transcript repair pairs tool calls/results and sanitizes tool inputs. |
1 | 2 | import type { AgentMessage } from "openclaw/plugin-sdk/agent-core"; |
2 | 3 | import { describe, expect, it } from "vitest"; |
3 | 4 | import { |
@@ -19,6 +20,7 @@ const TOOL_CALL_BLOCK_TYPES = new Set([
|
19 | 20 | ]); |
20 | 21 | |
21 | 22 | function getAssistantToolCallBlocks(messages: AgentMessage[]) { |
| 23 | +// Helper inspects all legacy/current tool-call block spellings in assistant content. |
22 | 24 | const assistant = messages[0] as Extract<AgentMessage, { role: "assistant" }> | undefined; |
23 | 25 | if (!assistant || !Array.isArray(assistant.content)) { |
24 | 26 | return [] as Array<{ type?: unknown; id?: unknown; name?: unknown }>; |
@@ -149,6 +151,7 @@ describe("sanitizeToolUseResultPairing", () => {
|
149 | 151 | }); |
150 | 152 | |
151 | 153 | it("keeps parallel tool results when code-mode display turns arrive first", () => { |
| 154 | +// Display-only assistant turns must not cause synthetic results before real results arrive. |
152 | 155 | const input = castAgentMessages([ |
153 | 156 | { |
154 | 157 | role: "assistant", |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Verifies session write locks handle reentrancy, stale locks, and symlinked paths. |
1 | 2 | import { spawn } from "node:child_process"; |
2 | 3 | import fsSync from "node:fs"; |
3 | 4 | import fs from "node:fs/promises"; |
@@ -22,6 +23,7 @@ async function expectLockRemovedOnlyAfterFinalRelease(params: {
|
22 | 23 | firstLock: { release: () => Promise<void> }; |
23 | 24 | secondLock: { release: () => Promise<void> }; |
24 | 25 | }) { |
| 26 | +// Reentrant locks share one file; only the final release removes it. |
25 | 27 | await expect(fs.access(params.lockPath)).resolves.toBeUndefined(); |
26 | 28 | await params.firstLock.release(); |
27 | 29 | await expect(fs.access(params.lockPath)).resolves.toBeUndefined(); |
@@ -109,6 +111,7 @@ async function withSymlinkedSessionPaths(
|
109 | 111 | linkLockPath: string; |
110 | 112 | }) => Promise<void>, |
111 | 113 | ) { |
| 114 | +// Symlinked session paths must resolve to the same lock ownership boundary. |
112 | 115 | if (process.platform === "win32") { |
113 | 116 | return; |
114 | 117 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Verifies sessions_spawn lifecycle hooks, binding cleanup, and gateway calls. |
1 | 2 | import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 3 | import { |
3 | 4 | createSubagentSpawnTestConfig, |
@@ -57,6 +58,7 @@ let resetSubagentRegistryForTests: typeof import("./subagent-registry.js").reset
|
57 | 58 | let spawnSubagentDirect: typeof import("./subagent-spawn.js").spawnSubagentDirect; |
58 | 59 | |
59 | 60 | function getGatewayRequests(): GatewayRequest[] { |
| 61 | +// Gateway call list is the observable side effect for spawn orchestration. |
60 | 62 | return hoisted.callGatewayMock.mock.calls.map((call) => call[0] as GatewayRequest); |
61 | 63 | } |
62 | 64 | |
@@ -179,6 +181,7 @@ function expectThreadBindFailureCleanup(
|
179 | 181 | result: { childSessionKey?: string; error?: string }, |
180 | 182 | pattern: RegExp, |
181 | 183 | ): void { |
| 184 | +// Failed child-thread binding must delete the child before agent startup. |
182 | 185 | expect(result.error).toMatch(pattern); |
183 | 186 | expect(hookRunnerMocks.runSubagentSpawned).not.toHaveBeenCalled(); |
184 | 187 | expectSessionsDeleteWithoutAgentStart(); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Verifies exec shell snapshots capture safe startup state without leaking secrets. |
1 | 2 | import { spawnSync } from "node:child_process"; |
2 | 3 | import fs from "node:fs"; |
3 | 4 | import os from "node:os"; |
@@ -38,6 +39,7 @@ function setSnapshotStateForTest(
|
38 | 39 | stateDir: string, |
39 | 40 | options: { home?: string; zdotdir?: string } = {}, |
40 | 41 | ): void { |
| 42 | +// Snapshot tests mutate trusted process env, not per-command untrusted env. |
41 | 43 | process.env.OPENCLAW_STATE_DIR = stateDir; |
42 | 44 | if (options.home) { |
43 | 45 | process.env.HOME = options.home; |
@@ -106,6 +108,7 @@ describe("exec shell snapshots", () => {
|
106 | 108 | }); |
107 | 109 | |
108 | 110 | it("does not honor per-call env for selecting the snapshot state dir", async () => { |
| 111 | +// Per-call env may be model/tool-controlled, so snapshot roots come from process env. |
109 | 112 | const trustedStateDir = fs.mkdtempSync( |
110 | 113 | path.join(os.tmpdir(), "openclaw-snapshot-trusted-state-"), |
111 | 114 | ); |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Verifies shell selection, PATH lookup, and platform-specific shell helpers. |
1 | 2 | import fs from "node:fs"; |
2 | 3 | import os from "node:os"; |
3 | 4 | import path from "node:path"; |
@@ -19,6 +20,7 @@ function createTempCommandDir(
|
19 | 20 | tempDirs: string[], |
20 | 21 | files: Array<{ name: string; executable?: boolean }>, |
21 | 22 | ): string { |
| 23 | +// Temporary PATH entries model available shell binaries and permissions. |
22 | 24 | const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-shell-")); |
23 | 25 | tempDirs.push(dir); |
24 | 26 | for (const file of files) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Verifies simple-completion model selection preserves provider, model, and profile refs. |
1 | 2 | import { describe, expect, it } from "vitest"; |
2 | 3 | import type { OpenClawConfig } from "../config/config.js"; |
3 | 4 | import { resolveSimpleCompletionSelectionForAgent } from "./simple-completion-runtime.js"; |
4 | 5 | |
5 | 6 | function requireSelection(selection: ReturnType<typeof resolveSimpleCompletionSelectionForAgent>) { |
| 7 | +// Narrows absent selections so each case can assert parsed provider/model fields. |
6 | 8 | if (!selection) { |
7 | 9 | throw new Error("expected simple completion selection"); |
8 | 10 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。