Files
claude-code/packages/builtin-tools/src/tools/ExecuteTool/__tests__/ExecuteTool.test.ts
xiaoFjun-eng ea399f1862 Fix type (#1239)
* 完善所有用到的type对象,并添加中文注释

* 补充遗失的type
2026-05-19 09:05:04 +08:00

33 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* ExecuteTool.test.ts
*
* 薄层子进程包装器,在独立的 bun:test 进程中运行实际测试。
* 这样可以防止其他测试文件的 mock.module() 漏出(例如 agentToolUtils.test.ts
* 对 src/Tool.js 的 mock影响 ExecuteTool 的测试。
*/
import { describe, test, expect } from 'bun:test'
import { resolve, relative } from 'path'
const PROJECT_ROOT = resolve(__dirname, '..', '..', '..', '..', '..')
const RUNNER_ABS = resolve(__dirname, 'ExecuteTool.runner.ts')
const RUNNER_REL = './' + relative(PROJECT_ROOT, RUNNER_ABS).replace(/\\/g, '/')
describe('ExecuteTool', () => {
test('runs all ExecuteTool tests in isolated subprocess', async () => {
const proc = Bun.spawn(['bun', 'test', RUNNER_REL], {
cwd: PROJECT_ROOT,
stdout: 'pipe',
stderr: 'pipe',
})
const code = await proc.exited
if (code !== 0) {
const stderr = await new Response(proc.stderr).text()
const stdout = await new Response(proc.stdout).text()
const output = (stderr + '\n' + stdout).slice(-3000)
throw new Error(
`ExecuteTool test subprocess failed (exit ${code}):\n${output}`,
)
}
}, 60_000)
})