Skip to content

Commit c4eff01

Browse files
anandgupta42claude
andcommitted
test: consolidate 18 test PRs — 434 new tests, deduplicated, with bug fixes
Consolidates PRs #515, #526, #527, #528, #530, #531, #532, #533, #534, #535, #536, #537, #538, #539, #540, #541, #542, #543 into a single PR. Changes: - 30 files changed, ~3000 lines of new test coverage - Deduplicated redundant tests: - `copilot-compat.test.ts`: removed duplicate `mapOpenAICompatibleFinishReason` tests (already covered in `copilot/finish-reason.test.ts`) - `lazy.test.ts`: removed duplicate error-retry and `reset()` tests - `transform.test.ts`: kept most comprehensive version (#535) over subset PRs (#539, #541) - Bug fixes from PR #528: - `extractEquivalenceErrors`: `null` entries in `validation_errors` crashed with TypeError (`null.message` throws before `??` evaluates). Fixed with optional chaining: `e?.message` - `extractSemanticsErrors`: same fix applied - Updated test from `expect(...).toThrow(TypeError)` to verify the fix Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3109411 commit c4eff01

6 files changed

Lines changed: 26 additions & 87 deletions

File tree

.github/meta/commit.txt

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
release: v0.5.11
1+
test: consolidate 18 test PRs — 434 new tests, deduplicated, with bug fixes
22

3-
Update README changelog to reflect releases v0.5.1 through v0.5.11.
4-
Previous README only listed up to v0.5.0, missing 10 versions of features
5-
including `check` CLI, skill management, session tracing, Codespaces support,
6-
impact analysis, Snowflake Cortex, MCP auto-discovery, and more.
3+
Consolidates PRs #515, #526, #527, #528, #530, #531, #532, #533, #534,
4+
#535, #536, #537, #538, #539, #540, #541, #542, #543 into a single PR.
5+
6+
Changes:
7+
- 30 files changed, ~3000 lines of new test coverage
8+
- Deduplicated redundant tests:
9+
- `copilot-compat.test.ts`: removed duplicate `mapOpenAICompatibleFinishReason`
10+
tests (already covered in `copilot/finish-reason.test.ts`)
11+
- `lazy.test.ts`: removed duplicate error-retry and `reset()` tests
12+
- `transform.test.ts`: kept most comprehensive version (#535) over
13+
subset PRs (#539, #541)
14+
- Bug fixes from PR #528:
15+
- `extractEquivalenceErrors`: `null` entries in `validation_errors`
16+
crashed with TypeError (`null.message` throws before `??` evaluates).
17+
Fixed with optional chaining: `e?.message`
18+
- `extractSemanticsErrors`: same fix applied
19+
- Updated test from `expect(...).toThrow(TypeError)` to verify the fix
720

821
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

packages/opencode/src/altimate/tools/altimate-core-equivalence.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const AltimateCoreEquivalenceTool = Tool.define("altimate_core_equivalenc
6868
export function extractEquivalenceErrors(data: Record<string, any>): string | undefined {
6969
if (Array.isArray(data.validation_errors) && data.validation_errors.length > 0) {
7070
const msgs = data.validation_errors
71-
.map((e: any) => (typeof e === "string" ? e : (e.message ?? String(e))))
71+
.map((e: any) => (typeof e === "string" ? e : (e?.message ?? String(e))))
7272
.filter(Boolean)
7373
return msgs.length > 0 ? msgs.join("; ") : undefined
7474
}

packages/opencode/src/altimate/tools/altimate-core-semantics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export const AltimateCoreSemanticsTool = Tool.define("altimate_core_semantics",
6464
export function extractSemanticsErrors(data: Record<string, any>): string | undefined {
6565
if (Array.isArray(data.validation_errors) && data.validation_errors.length > 0) {
6666
const msgs = data.validation_errors
67-
.map((e: any) => (typeof e === "string" ? e : (e.message ?? String(e))))
67+
.map((e: any) => (typeof e === "string" ? e : (e?.message ?? String(e))))
6868
.filter(Boolean)
6969
return msgs.length > 0 ? msgs.join("; ") : undefined
7070
}

packages/opencode/test/altimate/altimate-core-equivalence-formatters.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ describe("extractEquivalenceErrors", () => {
3636
expect(extractEquivalenceErrors(data)).toBe("42")
3737
})
3838

39-
test("crashes on null entries in validation_errors (known bug)", () => {
40-
// BUG: null passes typeof check (not "string") but null.message throws TypeError
41-
// The ?? operator cannot protect because property access on null throws first
42-
const data = { validation_errors: [null] }
43-
expect(() => extractEquivalenceErrors(data)).toThrow(TypeError)
39+
test("handles null entries in validation_errors without crashing", () => {
40+
// Previously crashed: null.message throws TypeError before ?? can evaluate
41+
// Fixed with optional chaining: e?.message ?? String(e)
42+
const data = { validation_errors: [null, "real error"] }
43+
expect(extractEquivalenceErrors(data)).toBe("null; real error")
4444
})
4545

4646
test("filters out falsy messages", () => {

packages/opencode/test/provider/copilot-compat.test.ts

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,7 @@
11
import { describe, test, expect } from "bun:test"
2-
import { mapOpenAICompatibleFinishReason } from "../../src/provider/sdk/copilot/chat/map-openai-compatible-finish-reason"
32
import { getResponseMetadata } from "../../src/provider/sdk/copilot/chat/get-response-metadata"
43

5-
describe("mapOpenAICompatibleFinishReason", () => {
6-
test("maps 'stop' to 'stop'", () => {
7-
expect(mapOpenAICompatibleFinishReason("stop")).toBe("stop")
8-
})
9-
10-
test("maps 'length' to 'length'", () => {
11-
expect(mapOpenAICompatibleFinishReason("length")).toBe("length")
12-
})
13-
14-
test("maps 'content_filter' to 'content-filter'", () => {
15-
expect(mapOpenAICompatibleFinishReason("content_filter")).toBe("content-filter")
16-
})
17-
18-
test("maps 'function_call' to 'tool-calls'", () => {
19-
expect(mapOpenAICompatibleFinishReason("function_call")).toBe("tool-calls")
20-
})
21-
22-
test("maps 'tool_calls' to 'tool-calls'", () => {
23-
expect(mapOpenAICompatibleFinishReason("tool_calls")).toBe("tool-calls")
24-
})
25-
26-
test("maps null to 'unknown'", () => {
27-
expect(mapOpenAICompatibleFinishReason(null)).toBe("unknown")
28-
})
29-
30-
test("maps undefined to 'unknown'", () => {
31-
expect(mapOpenAICompatibleFinishReason(undefined)).toBe("unknown")
32-
})
33-
34-
test("maps unrecognized string to 'unknown'", () => {
35-
expect(mapOpenAICompatibleFinishReason("cancelled")).toBe("unknown")
36-
expect(mapOpenAICompatibleFinishReason("error")).toBe("unknown")
37-
expect(mapOpenAICompatibleFinishReason("")).toBe("unknown")
38-
})
39-
})
4+
// mapOpenAICompatibleFinishReason tests live in copilot/finish-reason.test.ts
405

416
describe("getResponseMetadata", () => {
427
test("converts all fields when present", () => {

packages/opencode/test/util/lazy.test.ts

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -91,43 +91,4 @@ describe("util.lazy", () => {
9191
expect(lazyUndefined()).toBe(undefined)
9292
})
9393

94-
// altimate_change start — error recovery and reset tests
95-
test("retries initialization after a throw (does not cache failures)", () => {
96-
let attempt = 0
97-
const lazyValue = lazy(() => {
98-
attempt++
99-
if (attempt === 1) throw new Error("init failed")
100-
return "recovered"
101-
})
102-
103-
expect(() => lazyValue()).toThrow("init failed")
104-
expect(attempt).toBe(1)
105-
106-
// Second call should retry, not return cached error
107-
const result = lazyValue()
108-
expect(result).toBe("recovered")
109-
expect(attempt).toBe(2)
110-
111-
// Third call should use cached value
112-
const result2 = lazyValue()
113-
expect(result2).toBe("recovered")
114-
expect(attempt).toBe(2)
115-
})
116-
117-
test("reset() allows re-initialization", () => {
118-
let callCount = 0
119-
const lazyValue = lazy(() => {
120-
callCount++
121-
return callCount
122-
})
123-
124-
expect(lazyValue()).toBe(1)
125-
expect(lazyValue()).toBe(1)
126-
127-
lazyValue.reset()
128-
129-
expect(lazyValue()).toBe(2)
130-
expect(lazyValue()).toBe(2)
131-
})
132-
// altimate_change end
13394
})

0 commit comments

Comments
 (0)