Files
plugins/packages/agy-cli/agy-cli.test.mjs
T
tungloongandtungloong a2e601dc21 agy-cli 0.1.28: tool schemas with $ref/allOf/oneOf reach the model with their fields (#1042)
Tool schemas that use $ref, allOf or oneOf now reach the model with all their fields (expandToolSchema).

Nullable unions are lowered to type:[X,"null"]. Inlining is capped by depth (counted only along $ref and allOf), by 8192 nodes and by 256 KiB. A tool with no schema gets a plain object. The ToolSearch fallback was dropped.

Run at 80d19737 merged with main 16e753e8: `bun test packages/agy-cli` 16 pass, check ok.

Broken by hand: lowering a nullable union to a single type makes 1 test fail, and removing the byte cap makes 1 test fail.

Not tried: a real agy turn with these schemas.

Co-authored-by: tungloong <tungloong@users.noreply.github.com>
2026-11-13 00:23:26 +08:00

57 lines
2.0 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],
["step-usage.mjs", false],
["tool-schema.mjs", false],
["usage-settlement.mjs", false],
["repeat-batch.mjs", false],
["conversation-key.mjs", false],
["windows-nc.mjs", false],
]) {
test(`test/${name}`, () => {
// bun's 5s default per test is a fixed wait these process-spawning tests
// overrun on a loaded machine; the 240s run bounds a real hang.
const { code, output } = run(["test", "--timeout", "120000", ...(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)