Files
plugins/packages/agy-cli/agy-cli.test.mjs
T
yetoneandklarkxy dbd082f6d1 agy-cli 0.1.15: an array tool schema whose items live only on a sibling gets an items schema Gemini accepts (klarkxy #963)
Gemini refuses an array schema with no `items`. array-items.mjs infers
the items from the schema around it, or adds a permissive items schema 8
levels deep, without narrowing what the client allowed; tuple `items`
lists are left as they are, with a hint. Closes #962.

Reviewed head c7d3e7b8 (on c27ba5f7), landed onto main 738fd501 with the
version moved to 0.1.15 and package.json `files` keeping both
re2-pattern.mjs (#946) and array-items.mjs.
Run at the reviewed head: WSL2 bun test packages/agy-cli 9 of 9,
check.mjs ok; Windows 8 pass, 1 fail, the same smoke red as main (#973).
Broken by hand: without the ensureGeminiArrayItems call in normalizeTools
smoke.mjs reports 2 failures; PERMISSIVE_ARRAY_DEPTH = 1 and removing
`if (openArray) return null` each turn a test red.
Run at this commit (WSL2 Ubuntu 24.04, Bun 1.4.2, temp HOME): bun test
packages/agy-cli 10 of 10 pass; bun scripts/check.mjs agy-cli ok;
npm pack --dry-run lists 14 files, both new modules among them.
Not tried: macOS (mote refused ssh), a real agy.

Closes #963

Co-authored-by: klarkxy <klarkxy@users.noreply.github.com>
2026-11-11 13:35:07 +08:00

51 lines
1.7 KiB
JavaScript

// Runs the suites in test/ (brought over from gitxm/yce-magpie-agy, MIT), each
// in a bun process of its own: they mock node:child_process, move the clock and
// set the bridge's environment, and smoke.mjs ends with process.exit.
import { expect, test } from "bun:test"
import path from "node:path"
const dir = path.join(import.meta.dir, "test")
const hook = path.join(dir, "cp-hook.mjs")
function run(args, timeout) {
const result = Bun.spawnSync({ cmd: [process.execPath, ...args], cwd: dir, env: { ...process.env }, stdout: "pipe", stderr: "pipe", timeout })
const output = result.stdout.toString() + result.stderr.toString()
if (result.exitCode !== 0) console.error(output)
return { code: result.exitCode, output }
}
for (const [name, mocks] of [
["platform.mjs", true],
["compat.mjs", true],
["prefill.mjs", false],
["usage.mjs", true],
["catalog.mjs", false],
["usage-settlement.mjs", false],
["repeat-batch.mjs", false],
]) {
test(`test/${name}`, () => {
const { code, output } = run(["test", ...(mocks ? ["--preload", hook] : []), `./${name}`], 240_000)
expect(output).toMatch(/\b[1-9]\d* pass\b/)
expect(code).toBe(0)
}, 250_000)
}
test("test/re2-pattern-unit.mjs", () => {
const { code, output } = run([path.join(dir, "re2-pattern-unit.mjs")], 60_000)
expect(output).toMatch(/ALL OK/)
expect(code).toBe(0)
}, 70_000)
test("test/smoke.mjs against a fake agy", () => {
const { code, output } = run([path.join(dir, "smoke.mjs")], 240_000)
expect(output).toMatch(/ALL OK \(\d+ checks\)/)
expect(code).toBe(0)
}, 250_000)
test("test/array-items-unit.mjs", () => {
const { code, output } = run([path.join(dir, "array-items-unit.mjs")], 60_000)
expect(output).toMatch(/ALL OK/)
expect(code).toBe(0)
}, 70_000)