补齐遗漏日志: 服务日志/看门狗日志, 并归档上一轮遗留的测试产物
用户问"日志都上传了吗", 一查发现确有遗漏: - server.log (427KB, 写至 10-13) 与 keep_display.log (看门狗, 12.5KB), lc_mcp.log 此前只上传了 runs/ 下的 20 份任务日志, 这三个漏了。 - 10-02/10-03 那轮会话遗留在仓库根目录的测试产物从未提交, 一直显示为未跟踪。 本次补上: - logs/full/ 增加 server.log.gz / keep_display.log.gz / lc_mcp.log.gz - logs/keep_display-watchdog.txt 为看门狗日志全文(177 行), 完整记录了 "RDP 一断开就提权 tscon 切回物理 console" 的每次触发, 即被要求关闭的那支脚本的行为证据。 - logs/server-excerpt.txt 为服务日志摘录(52 行)。 - 10-02 的测试产物归档到 docs/feedback/2026-10-02/validation/ 并附 README 说明, PHYSICAL_INPUT_CHANGE.md 归到 2026-10-03/。 注: tests/*.py 归档后不在 tests/ 目录, 不会被 unittest discover 收集; 此为保留证据链的有意选择, 已在 README 中注明。
This commit is contained in:
@@ -0,0 +1,33 @@
|
|||||||
|
# 2026-10-02 测试产物归档
|
||||||
|
|
||||||
|
这些文件是 **2026-10-02 那轮会话**产生并遗留在仓库根目录、一直未被提交的
|
||||||
|
测试产物。2026-10-13 按用户要求归档到这个位置,让测试代码与结果
|
||||||
|
跟对应的日期记录放在一起,仓库根目录不再散落未跟踪文件。
|
||||||
|
|
||||||
|
## 内容
|
||||||
|
|
||||||
|
| 文件 | 说明 |
|
||||||
|
|---|---|
|
||||||
|
| `TEST_REPORT.md` | 当轮测试报告 |
|
||||||
|
| `validation-output.txt` | 单测运行输出(`test_click_text_second_hit` / `test_get_state` / `test_missing_text_does_not_click` / `test_ocr_confidence_filter` / `test_ocr_error_does_not_click` / `test_protocol_discovery_and_all_input_tools` 等) |
|
||||||
|
| `validation-results.json` | 上式的结构化结果 |
|
||||||
|
| `live-service-results.json` | 对**常驻服务**(非 FakeEngine)的实测结果 |
|
||||||
|
| `sdk-client-results.json` | SDK 客户端实测结果 |
|
||||||
|
| `tests/live_services_v05.py` | 常驻服务实测脚本 |
|
||||||
|
| `tests/validation_v05.py` | 校验脚本(v0.5) |
|
||||||
|
| `validation-artifacts/ocr-synthetic.png` | OCR 合成测试图 |
|
||||||
|
| `validation-artifacts/run-original.vbs` | 复现用启动脚本 |
|
||||||
|
|
||||||
|
## 两点说明
|
||||||
|
|
||||||
|
1. **这些不是本次无人值守部署(10-04 / 10-05)的产物。** 那两天的记录在
|
||||||
|
`docs/feedback/2026-10-04/` 与 `docs/feedback/2026-10-05/`。
|
||||||
|
2. `tests/*.py` 归档到这里是为了保留证据链,**它们不在 `tests/` 目录下
|
||||||
|
就不会被 `python -m unittest discover -s tests` 收集**。若希望它们
|
||||||
|
参与常规测试,需要移回 `tests/` 并确认通过。
|
||||||
|
|
||||||
|
## 相关提交
|
||||||
|
|
||||||
|
- `docs/feedback/2026-10-04/README.md` — 无人值守部署:6 个失败根因 + 自愈看门狗
|
||||||
|
- `docs/feedback/2026-10-05/PITFALLS.md` — 自动化实战:14 个坑
|
||||||
|
- `docs/feedback/2026-10-05/logs/` — 20 份任务日志 + 服务/看门狗日志
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
# lc-mcp 测试报告
|
||||||
|
|
||||||
|
测试日期:2026-10-02(Asia/Hong_Kong)。
|
||||||
|
|
||||||
|
仓库:https://git.lingll.icu/yws/lc-mcp
|
||||||
|
|
||||||
|
测试提交:`8d24276511e2f007a758b180cba7167e58aca090`,main,服务版本 0.5.0。
|
||||||
|
|
||||||
|
## 结论
|
||||||
|
|
||||||
|
基础 MCP 连接和远端 OCR 可用,但当前版本不能判定为可以可靠操作真实游戏。Windows 默认截图启动脚本存在可复现的 VBScript 编译错误;参数缺失会导致意外点击;输入和工具错误可能被报告为成功。应优先修复这三类问题,再做实际游戏闭环测试。
|
||||||
|
|
||||||
|
当前仓库实现独立的屏幕 OCR 和桌面输入,没有找到 AALC 的 API 调用、配置、依赖或游戏状态集成。是否来自 AALC 的设计或早期代码,无法从本次仓库内容确定。
|
||||||
|
|
||||||
|
## 环境与范围
|
||||||
|
|
||||||
|
- Windows 本机;服务使用已安装的 Python 3.8.6。
|
||||||
|
- 官方 MCP Python SDK 1.30.0 客户端运行于独立 Python 3.12.14 虚拟环境。
|
||||||
|
- 远端 OCR 使用仓库默认地址,上传内容仅为生成的测试 PNG。
|
||||||
|
- 输入测试使用 mock 或模拟底层调用失败,没有向真实桌面发送点击、按键或文字。
|
||||||
|
- 没有检测到正在运行的 LimbusCompany/AALC 进程。实际游戏窗口、战斗、奖励结算和 AALC 联动均未验证。
|
||||||
|
- Linux uinput 检查使用模拟依赖复现 Python 错误,并核对上游数据类型;没有 Linux 内核或 macOS 实机测试。
|
||||||
|
- Windows VBScript 使用相同生成表达式、隔离文件路径,通过 `cscript.exe` 编译检查。没有覆盖或运行现有 LcMCP 计划任务。
|
||||||
|
- 仅新增测试和报告文件,没有修改原有实现、提交或推送代码。
|
||||||
|
|
||||||
|
## 测试结果
|
||||||
|
|
||||||
|
| 检查 | 结果 | 证据 |
|
||||||
|
|---|---|---|
|
||||||
|
| 自带测试 | 3 组全部通过 | mock 动作、扫描码表、stdio 往返 |
|
||||||
|
| Python 编译检查 | 通过 | `python -m compileall -q .` |
|
||||||
|
| 独立测试 | 22 项:11 通过、9 断言失败、2 运行异常 | `validation-results.json`;失败项是边界行为复现,不代表 11 个独立缺陷 |
|
||||||
|
| 官方 SDK 连接 | 通过 | initialize、ping、tools/list;识别 9 个工具 |
|
||||||
|
| SDK 模拟输入 | 通过 | move、中文 type_text |
|
||||||
|
| 远端 OCR | 通过 | 正确识别“开始 测试”和“TEST 123”;置信度 0.944、0.960 |
|
||||||
|
| OCR 延迟 | 单次 19.515 秒 | 仅一次请求,不能视为稳定性能或游戏图像准确率 |
|
||||||
|
| Windows 截图启动脚本 | 失败 | VBScript 编译器错误:语句未结束;退出码 1 |
|
||||||
|
| SendInput 初始化 | 通过 | 只加载后端,没有发送输入 |
|
||||||
|
| Interception 初始化 | 环境不满足 | 本机未找到 interception.dll;没有安装驱动或重启 |
|
||||||
|
|
||||||
|
正常语义流程的模拟测试覆盖:OCR 置信度过滤、文字子串和大小写匹配、中心坐标计算、第二候选点击、文字找不到时不点击、OCR 失败时不点击、截图失败透传、文字出现和消失等待。
|
||||||
|
|
||||||
|
## 主要发现
|
||||||
|
|
||||||
|
### 1. Windows 截图启动脚本无法编译(P1)
|
||||||
|
|
||||||
|
位置:[platform/win.py:20](D:/codex/tmp/lc-mcp-test/platform/win.py:20)。
|
||||||
|
|
||||||
|
生成的脚本在 VBScript 字符串内部直接使用单个双引号包围 PowerShell 脚本路径,提前结束了字符串。VBScript 需要将字符串内部双引号写为两个双引号。
|
||||||
|
|
||||||
|
复现产物为 `validation-artifacts/run-original.vbs`。执行 `cscript.exe //nologo <该文件>` 返回 1,报“Microsoft VBScript 编译器错误:语句未结束”。
|
||||||
|
|
||||||
|
影响:使用默认生成脚本的新部署不能启动截图任务,进而阻断 screenshot、get_state 和依赖 OCR 的工具。已有自定义修正脚本的机器需单独验证;代码仅在文件不存在时生成脚本,更新 Python 代码也不会自动刷新旧脚本。
|
||||||
|
|
||||||
|
### 2. 必需参数没有运行时校验,可能意外点击(P1)
|
||||||
|
|
||||||
|
位置:[lc_mcp.py:117](D:/codex/tmp/lc-mcp-test/lc_mcp.py:117)、[lc_mcp.py:131](D:/codex/tmp/lc-mcp-test/lc_mcp.py:131)。
|
||||||
|
|
||||||
|
- `click({})` 被默认值转换为点击 `(0,0)`,返回 `ok=true`。官方 SDK 客户端复现相同行为。
|
||||||
|
- `click_text({})` 使用空字符串匹配所有 OCR 项,并点击第一个文字中心。
|
||||||
|
- `index=99` 静默选择最后一个候选;`index=-1` 也选择最后一个候选。这是当前行为,接口没有说明索引越界规则。
|
||||||
|
|
||||||
|
影响:客户端遗漏参数或模型选择错误索引时,服务仍可能执行桌面输入。建议在任何截图和输入之前校验必需参数、非空文字、索引整数和范围。
|
||||||
|
|
||||||
|
### 3. MCP 工具错误标记位置错误,客户端读成成功(P1)
|
||||||
|
|
||||||
|
位置:[lc_mcp.py:221](D:/codex/tmp/lc-mcp-test/lc_mcp.py:221)。
|
||||||
|
|
||||||
|
调用 `move({"x":"invalid","y":6})` 时,服务把 `isError=true` 放在 JSON-RPC 顶层,而不是 `result` 内部。官方 SDK 接收到文本里的 `ok=false`,但 `CallToolResult.isError` 实际为 false。
|
||||||
|
|
||||||
|
普通 `ok=false` 返回路径没有设置 `result.isError`;未知工具也返回普通文本结果。
|
||||||
|
|
||||||
|
工具执行错误应在 `result.isError` 中表达;未知工具和无效参数可用 JSON-RPC 错误。这与 [MCP 2024-11-05 Tools 规范](https://modelcontextprotocol.io/specification/2024-11-05/server/tools)不符。
|
||||||
|
|
||||||
|
### 4. SendInput 注入失败仍返回成功(P1)
|
||||||
|
|
||||||
|
位置:[backends/sendinput_win.py:54](D:/codex/tmp/lc-mcp-test/backends/sendinput_win.py:54)、[backends/sendinput_win.py:87](D:/codex/tmp/lc-mcp-test/backends/sendinput_win.py:87)。
|
||||||
|
|
||||||
|
模拟 `SendInput` 返回 0 后,`keypress('p')` 仍返回 `ok=true`。点击和文字输入也不检查注入数量;移动不检查 SetCursorPos 结果。
|
||||||
|
|
||||||
|
影响:服务返回成功不代表目标应用收到输入。需要检查底层调用结果,并在游戏环境用后续状态验证动作效果。本次没有实机验证游戏对 SendInput 的接受程度。
|
||||||
|
|
||||||
|
### 5. 等待 timeout 不约束内部截图和网络请求(P2)
|
||||||
|
|
||||||
|
位置:[lc_mcp.py:43](D:/codex/tmp/lc-mcp-test/lc_mcp.py:43)、[lc_mcp.py:140](D:/codex/tmp/lc-mcp-test/lc_mcp.py:140)。
|
||||||
|
|
||||||
|
用模拟时钟将一次 OCR 请求设为 30 秒,`wait_for_text(timeout=1)` 需要 31.2 秒才结束。请求固定使用 30 秒超时;截图也有自己的超时,外层没有传递剩余时间。
|
||||||
|
|
||||||
|
应使用单调时钟和剩余预算约束内部操作,避免短等待变成长阻塞。
|
||||||
|
|
||||||
|
### 6. 输入后端初始化失败同时禁用了截图(P2)
|
||||||
|
|
||||||
|
位置:[lc_mcp.py:171](D:/codex/tmp/lc-mcp-test/lc_mcp.py:171)。
|
||||||
|
|
||||||
|
截图提供者与输入后端共用一个 try/except。设置一个不存在的输入后端后,`screenshot` 返回 `'NoneType' object has no attribute 'grab'`,尽管截图提供者此前已成功创建。
|
||||||
|
|
||||||
|
应分别初始化和报告截图、输入能力;仅观察屏幕的工具不应依赖输入后端可用。
|
||||||
|
|
||||||
|
### 7. Linux uinput 后端存在确定的 Python 错误(P1,限该后端)
|
||||||
|
|
||||||
|
位置:[backends/uinput_linux.py:28](D:/codex/tmp/lc-mcp-test/backends/uinput_linux.py:28)、[backends/uinput_linux.py:72](D:/codex/tmp/lc-mcp-test/backends/uinput_linux.py:72)。
|
||||||
|
|
||||||
|
- `keypress('enter')` 引用未定义的 `KEY_ENTER`,抛 NameError。
|
||||||
|
- `_ensure()` 对 uinput 的元组常量执行 `KEY_Z + 1` 和 range,抛 TypeError。
|
||||||
|
- 其他输入路径引用未在模块作用域导入的 REL_X、BTN_LEFT 等常量;代码还缺少 time 导入。
|
||||||
|
|
||||||
|
前两项已通过隔离测试复现,后两项为源码检查。uinput 的事件描述符类型已核对 [python-uinput 上游实现](https://raw.githubusercontent.com/tuomasjjrasanen/python-uinput/master/src/__init__.py)。
|
||||||
|
|
||||||
|
### 8. Interception 实现与上游公开 API 不一致(待实机确认)
|
||||||
|
|
||||||
|
位置:[backends/interception_win.py:91](D:/codex/tmp/lc-mcp-test/backends/interception_win.py:91)。
|
||||||
|
|
||||||
|
代码调用 interception_open_device/interception_close_device,但 [上游公开头文件](https://raw.githubusercontent.com/oblitum/Interception/master/library/interception.h)没有这两个接口。上游设备总数为 20,代码扫描到 64,且硬件 ID 被按 ASCII 文本解释。
|
||||||
|
|
||||||
|
这是源码与上游接口比对发现,本机缺少 DLL,未测试实际加载的 DLL 是否为提供这些接口的定制版本。部署前应明确支持的 DLL 版本并用真实设备验证。
|
||||||
|
|
||||||
|
### 9. 畸形 JSON 使服务退出(P2,健壮性)
|
||||||
|
|
||||||
|
向 stdio 发送 `{ invalid json }` 后,服务直接关闭 stdout 并退出,没有返回 JSON-RPC parse error。这会断开客户端连接。有效请求的正常流程不受本测试影响。
|
||||||
|
|
||||||
|
## 复现文件
|
||||||
|
|
||||||
|
- [独立测试脚本](D:/codex/tmp/lc-mcp-test/tests/test_validation.py)
|
||||||
|
- [OCR 和 VBScript 检查脚本](D:/codex/tmp/lc-mcp-test/tests/test_live_services.py)
|
||||||
|
- [官方 SDK 客户端脚本](D:/codex/tmp/lc-mcp-sdk-client-test.py)(放在仓库外,避免仓库的 platform 包影响客户端标准库导入)
|
||||||
|
- [逐项测试结果](D:/codex/tmp/lc-mcp-test/validation-results.json)
|
||||||
|
- [OCR、VBScript 与后端初始化结果](D:/codex/tmp/lc-mcp-test/live-service-results.json)
|
||||||
|
- [官方 SDK 返回结果](D:/codex/tmp/lc-mcp-test/sdk-client-results.json)
|
||||||
|
- [生成的 OCR 测试图](D:/codex/tmp/lc-mcp-test/validation-artifacts/ocr-synthetic.png)
|
||||||
|
|
||||||
|
执行服务端测试:`python tests/test_dev.py`、`python tests/test_validation.py`、`python tests/test_live_services.py`。后者需要 Pillow、Windows 字体和网络;当前本机已有所需图像依赖。独立验证脚本当前返回非零是预期结果,因为其断言要求服务拒绝错误输入并正确报告失败。
|
||||||
|
|
||||||
|
## 下一步
|
||||||
|
|
||||||
|
先修复 Windows 脚本生成、参数校验、MCP 错误返回和底层输入结果检查,再准备可观察的游戏窗口,逐步验证“截图 → OCR → 正确候选 → 单次输入 → 新截图确认”。真实游戏测试需要运行机器和窗口状态;本次结果不包含战斗自动化成功率或 AALC 集成验证。
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"remote_ocr": {
|
||||||
|
"url": "http://35.212.193.150:8599/",
|
||||||
|
"seconds": 19.515,
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"text": "开始 测试",
|
||||||
|
"x": 37,
|
||||||
|
"y": 39,
|
||||||
|
"w": 230,
|
||||||
|
"h": 59,
|
||||||
|
"score": 0.944
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "TEST 123",
|
||||||
|
"x": 40,
|
||||||
|
"y": 143,
|
||||||
|
"w": 226,
|
||||||
|
"h": 47,
|
||||||
|
"score": 0.96
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"error": null,
|
||||||
|
"input": "D:\\codex\\tmp\\lc-mcp-test\\validation-artifacts\\ocr-synthetic.png"
|
||||||
|
},
|
||||||
|
"windows_vbs": {
|
||||||
|
"returncode": 1,
|
||||||
|
"stdout": "",
|
||||||
|
"stderr": "D:\\codex\\tmp\\lc-mcp-test\\validation-artifacts\\run-original.vbs(1, 93) Microsoft VBScript 编译器错误: 语句未结束\r\n\r\n",
|
||||||
|
"script": "CreateObject(\"WScript.Shell\").Run \"powershell.exe -NoProfile -ExecutionPolicy Bypass -File \"D:\\codex\\tmp\\lc-mcp-test\\validation-artifacts\\nonexistent-test-job.ps1\"\", 0, False\n"
|
||||||
|
},
|
||||||
|
"sendinput_initialization": {
|
||||||
|
"ok": true
|
||||||
|
},
|
||||||
|
"interception_initialization": {
|
||||||
|
"ok": false,
|
||||||
|
"error": "Could not find module 'interception.dll' (or one of its dependencies). Try using the full path with constructor syntax."
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
{
|
||||||
|
"sdk_version": "1.30.0",
|
||||||
|
"initialize": {
|
||||||
|
"meta": null,
|
||||||
|
"protocolVersion": "2024-11-05",
|
||||||
|
"capabilities": {
|
||||||
|
"experimental": null,
|
||||||
|
"logging": null,
|
||||||
|
"prompts": null,
|
||||||
|
"resources": null,
|
||||||
|
"tools": {
|
||||||
|
"listChanged": false
|
||||||
|
},
|
||||||
|
"completions": null,
|
||||||
|
"tasks": null
|
||||||
|
},
|
||||||
|
"serverInfo": {
|
||||||
|
"name": "lc-mcp",
|
||||||
|
"title": null,
|
||||||
|
"version": "0.5.0",
|
||||||
|
"websiteUrl": null,
|
||||||
|
"icons": null
|
||||||
|
},
|
||||||
|
"instructions": null
|
||||||
|
},
|
||||||
|
"ping": "PASS",
|
||||||
|
"tools": [
|
||||||
|
"get_state",
|
||||||
|
"click_text",
|
||||||
|
"wait_for_text",
|
||||||
|
"wait_for_text_gone",
|
||||||
|
"screenshot",
|
||||||
|
"click",
|
||||||
|
"move",
|
||||||
|
"keypress",
|
||||||
|
"type_text"
|
||||||
|
],
|
||||||
|
"calls": [
|
||||||
|
{
|
||||||
|
"name": "move",
|
||||||
|
"arguments": {
|
||||||
|
"x": 5,
|
||||||
|
"y": 6
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"meta": null,
|
||||||
|
"content": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": "{\"ok\": true, \"backend\": \"mock\"}",
|
||||||
|
"annotations": null,
|
||||||
|
"meta": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"structuredContent": null,
|
||||||
|
"isError": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "type_text",
|
||||||
|
"arguments": {
|
||||||
|
"text": "测试"
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"meta": null,
|
||||||
|
"content": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": "{\"ok\": true, \"typed\": \"测试\", \"backend\": \"mock\"}",
|
||||||
|
"annotations": null,
|
||||||
|
"meta": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"structuredContent": null,
|
||||||
|
"isError": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "move",
|
||||||
|
"arguments": {
|
||||||
|
"x": "invalid",
|
||||||
|
"y": 6
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"meta": null,
|
||||||
|
"content": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": "{\"ok\": false, \"error\": \"invalid literal for int() with base 10: 'invalid'\"}",
|
||||||
|
"annotations": null,
|
||||||
|
"meta": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"structuredContent": null,
|
||||||
|
"isError": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "click",
|
||||||
|
"arguments": {},
|
||||||
|
"result": {
|
||||||
|
"meta": null,
|
||||||
|
"content": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": "{\"ok\": true, \"clicked\": [0, 0], \"backend\": \"mock\"}",
|
||||||
|
"annotations": null,
|
||||||
|
"meta": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"structuredContent": null,
|
||||||
|
"isError": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "unknown",
|
||||||
|
"arguments": {},
|
||||||
|
"result": {
|
||||||
|
"meta": null,
|
||||||
|
"content": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": "{\"ok\": false, \"error\": \"unknown tool unknown\"}",
|
||||||
|
"annotations": null,
|
||||||
|
"meta": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"structuredContent": null,
|
||||||
|
"isError": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
"""Use only generated images; never send screenshots or desktop input."""
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
sys.path.insert(0, str(ROOT))
|
||||||
|
import lc_mcp as app
|
||||||
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
|
||||||
|
out = ROOT / 'validation-artifacts'
|
||||||
|
out.mkdir(exist_ok=True)
|
||||||
|
results = {}
|
||||||
|
image = Image.new('RGB', (900, 300), 'white')
|
||||||
|
draw = ImageDraw.Draw(image)
|
||||||
|
font = ImageFont.truetype('C:/Windows/Fonts/msyh.ttc', 52)
|
||||||
|
draw.text((40, 30), '开始 测试', font=font, fill='black')
|
||||||
|
draw.text((40, 130), 'TEST 123', font=font, fill='black')
|
||||||
|
path = out / 'ocr-synthetic.png'
|
||||||
|
image.save(str(path))
|
||||||
|
start = time.monotonic()
|
||||||
|
items, error = app.ocr_image(str(path))
|
||||||
|
results['remote_ocr'] = {'url': app.OCR_URL, 'seconds': round(time.monotonic() - start, 3),
|
||||||
|
'items': items, 'error': error, 'input': str(path)}
|
||||||
|
print(json.dumps({'remote_ocr': results['remote_ocr']}, ensure_ascii=True), flush=True)
|
||||||
|
|
||||||
|
# Exact script-generation expression from platform/win.py, with isolated paths.
|
||||||
|
job = str(out / 'nonexistent-test-job.ps1')
|
||||||
|
vbs = out / 'run-original.vbs'
|
||||||
|
vbs.write_text('CreateObject("WScript.Shell").Run "powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%s"", 0, False\n' % job, encoding='utf-8')
|
||||||
|
r = subprocess.run(['cscript.exe', '//nologo', str(vbs)], capture_output=True, timeout=10)
|
||||||
|
results['windows_vbs'] = {'returncode': r.returncode,
|
||||||
|
'stdout': r.stdout.decode('mbcs', errors='replace'), 'stderr': r.stderr.decode('mbcs', errors='replace'),
|
||||||
|
'script': vbs.read_text(encoding='utf-8')}
|
||||||
|
print(json.dumps({'windows_vbs': results['windows_vbs']}, ensure_ascii=True), flush=True)
|
||||||
|
for name in ('sendinput', 'interception'):
|
||||||
|
try:
|
||||||
|
backend = app.get_input_backend(name, 'win')
|
||||||
|
results[name + '_initialization'] = {'ok': True}
|
||||||
|
except Exception as e:
|
||||||
|
results[name + '_initialization'] = {'ok': False, 'error': str(e)}
|
||||||
|
(ROOT / 'live-service-results.json').write_text(json.dumps(results, ensure_ascii=False, indent=2), encoding='utf-8')
|
||||||
|
print(json.dumps(results, ensure_ascii=True), flush=True)
|
||||||
@@ -0,0 +1,251 @@
|
|||||||
|
"""Independent validation; no real desktop inputs are sent.
|
||||||
|
|
||||||
|
Run: python tests/test_validation.py
|
||||||
|
Failures assert the intended behavior and reproduce defects in the tested revision.
|
||||||
|
"""
|
||||||
|
import contextlib
|
||||||
|
import io
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import queue
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import threading
|
||||||
|
import unittest
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
sys.path.insert(0, str(ROOT))
|
||||||
|
import lc_mcp as app
|
||||||
|
from backends.mock import MockBackend
|
||||||
|
|
||||||
|
ITEMS = [
|
||||||
|
{'text': '开始', 'x': 100, 'y': 200, 'w': 80, 'h': 40, 'score': .99},
|
||||||
|
{'text': '开始战斗', 'x': 300, 'y': 400, 'w': 100, 'h': 50, 'score': .95},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class Provider:
|
||||||
|
def grab(self):
|
||||||
|
return {'ok': True, 'path': 'synthetic.png'}
|
||||||
|
|
||||||
|
|
||||||
|
class Peer:
|
||||||
|
def __init__(self, extra_env=None):
|
||||||
|
env = dict(os.environ, INPUT_BACKEND='mock', PYTHONIOENCODING='utf-8')
|
||||||
|
env.update(extra_env or {})
|
||||||
|
self.p = subprocess.Popen([sys.executable, str(ROOT / 'lc_mcp.py')],
|
||||||
|
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||||
|
text=True, encoding='utf-8', env=env)
|
||||||
|
self.q = queue.Queue()
|
||||||
|
def pump():
|
||||||
|
for line in self.p.stdout:
|
||||||
|
self.q.put(line)
|
||||||
|
self.q.put(None)
|
||||||
|
threading.Thread(target=pump, daemon=True).start()
|
||||||
|
|
||||||
|
def send(self, obj):
|
||||||
|
self.p.stdin.write(json.dumps(obj, ensure_ascii=True) + '\n')
|
||||||
|
self.p.stdin.flush()
|
||||||
|
line = self.q.get(timeout=5)
|
||||||
|
return json.loads(line) if line else None
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
if self.p.poll() is None:
|
||||||
|
self.p.kill()
|
||||||
|
self.p.communicate(timeout=5)
|
||||||
|
|
||||||
|
|
||||||
|
class HealthyPaths(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.b = MockBackend()
|
||||||
|
self.s = app.MCPServer('win', Provider(), self.b)
|
||||||
|
|
||||||
|
def test_text_coordinates(self):
|
||||||
|
self.assertEqual(app.calc_click('开始', ITEMS)[0], {'text': '开始', 'x': 140, 'y': 220})
|
||||||
|
|
||||||
|
def test_substring_case_insensitive(self):
|
||||||
|
items = [dict(ITEMS[0], text='Start Battle')]
|
||||||
|
self.assertEqual(len(app.calc_click('START', items)), 1)
|
||||||
|
|
||||||
|
def test_get_state(self):
|
||||||
|
with patch.object(app, 'ocr_image', return_value=(ITEMS, None)):
|
||||||
|
self.assertEqual(self.s.call('get_state', {})['items'], ITEMS)
|
||||||
|
|
||||||
|
def test_click_text_second_hit(self):
|
||||||
|
with patch.object(app, 'ocr_image', return_value=(ITEMS, None)):
|
||||||
|
self.s.call('click_text', {'text': '开始', 'index': 1})
|
||||||
|
self.assertEqual(self.b.log[-1]['x'], 350)
|
||||||
|
self.assertEqual(self.b.log[-1]['y'], 425)
|
||||||
|
|
||||||
|
def test_missing_text_does_not_click(self):
|
||||||
|
with patch.object(app, 'ocr_image', return_value=(ITEMS, None)):
|
||||||
|
self.assertFalse(self.s.call('click_text', {'text': '不存在'})['ok'])
|
||||||
|
self.assertEqual(self.b.log, [])
|
||||||
|
|
||||||
|
def test_ocr_error_does_not_click(self):
|
||||||
|
with patch.object(app, 'ocr_image', return_value=(None, 'service unavailable')):
|
||||||
|
self.assertFalse(self.s.call('click_text', {'text': '开始'})['ok'])
|
||||||
|
self.assertEqual(self.b.log, [])
|
||||||
|
|
||||||
|
def test_screenshot_error_propagates(self):
|
||||||
|
with patch.object(self.s.provider, 'grab', return_value={'ok': False, 'error': 'capture fail'}):
|
||||||
|
self.assertEqual(self.s.call('get_state', {})['error'], 'capture fail')
|
||||||
|
|
||||||
|
def test_wait_present(self):
|
||||||
|
with patch.object(app, 'ocr_image', return_value=(ITEMS, None)):
|
||||||
|
self.assertTrue(self.s.call('wait_for_text', {'text': '开始', 'timeout': 1})['present'])
|
||||||
|
|
||||||
|
def test_wait_absent(self):
|
||||||
|
with patch.object(app, 'ocr_image', return_value=([], None)):
|
||||||
|
result = self.s.call('wait_for_text_gone', {'text': '开始', 'timeout': 1})
|
||||||
|
self.assertTrue(result['ok'])
|
||||||
|
self.assertFalse(result['present'])
|
||||||
|
|
||||||
|
def test_ocr_confidence_filter(self):
|
||||||
|
payload = {'ok': True, 'items': ITEMS + [dict(ITEMS[0], score=.1)]}
|
||||||
|
response = contextlib.closing(io.BytesIO(json.dumps(payload).encode('utf-8')))
|
||||||
|
with tempfile.TemporaryDirectory() as tmp, patch.object(app.urllib.request, 'urlopen', return_value=response):
|
||||||
|
path = Path(tmp) / 'image.png'
|
||||||
|
path.write_bytes(b'fixture')
|
||||||
|
items, error = app.ocr_image(str(path))
|
||||||
|
self.assertIsNone(error)
|
||||||
|
self.assertEqual(len(items), 2)
|
||||||
|
|
||||||
|
def test_protocol_discovery_and_all_input_tools(self):
|
||||||
|
p = Peer()
|
||||||
|
try:
|
||||||
|
response = p.send({'jsonrpc': '2.0', 'id': 1, 'method': 'initialize', 'params': {}})
|
||||||
|
self.assertEqual(response['result']['serverInfo']['name'], 'lc-mcp')
|
||||||
|
response = p.send({'jsonrpc': '2.0', 'id': 2, 'method': 'tools/list'})
|
||||||
|
self.assertEqual(len(response['result']['tools']), 9)
|
||||||
|
for name, args in [('click', {'x': 10, 'y': 20}), ('move', {'x': 5, 'y': 6}),
|
||||||
|
('keypress', {'key': 'p'}), ('type_text', {'text': '开始'})]:
|
||||||
|
r = p.send({'jsonrpc': '2.0', 'id': 3, 'method': 'tools/call', 'params': {'name': name, 'arguments': args}})
|
||||||
|
self.assertTrue(json.loads(r['result']['content'][0]['text'])['ok'])
|
||||||
|
finally:
|
||||||
|
p.close()
|
||||||
|
|
||||||
|
|
||||||
|
class RequiredBehavior(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.b = MockBackend()
|
||||||
|
self.s = app.MCPServer('win', Provider(), self.b)
|
||||||
|
|
||||||
|
def test_missing_click_coordinates_rejected(self):
|
||||||
|
result = self.s.call('click', {})
|
||||||
|
self.assertFalse(result['ok'], result)
|
||||||
|
self.assertEqual(self.b.log, [])
|
||||||
|
|
||||||
|
def test_missing_click_text_rejected(self):
|
||||||
|
with patch.object(app, 'ocr_image', return_value=(ITEMS, None)):
|
||||||
|
result = self.s.call('click_text', {})
|
||||||
|
self.assertFalse(result['ok'], result)
|
||||||
|
self.assertEqual(self.b.log, [])
|
||||||
|
|
||||||
|
def test_out_of_range_index_rejected(self):
|
||||||
|
with patch.object(app, 'ocr_image', return_value=(ITEMS, None)):
|
||||||
|
result = self.s.call('click_text', {'text': '开始', 'index': 99})
|
||||||
|
self.assertFalse(result['ok'], result)
|
||||||
|
|
||||||
|
def test_negative_index_rejected(self):
|
||||||
|
with patch.object(app, 'ocr_image', return_value=(ITEMS, None)):
|
||||||
|
result = self.s.call('click_text', {'text': '开始', 'index': -1})
|
||||||
|
self.assertFalse(result['ok'], result)
|
||||||
|
|
||||||
|
def test_wait_timeout_honored(self):
|
||||||
|
clock = [0.0]
|
||||||
|
def slow_ocr(_):
|
||||||
|
clock[0] += 30
|
||||||
|
return None, 'network timeout'
|
||||||
|
def sleep(seconds):
|
||||||
|
clock[0] += seconds
|
||||||
|
with patch.object(app.time, 'time', side_effect=lambda: clock[0]), \
|
||||||
|
patch.object(app.time, 'sleep', side_effect=sleep), \
|
||||||
|
patch.object(app, 'ocr_image', side_effect=slow_ocr):
|
||||||
|
self.s.call('wait_for_text', {'text': '开始', 'timeout': 1})
|
||||||
|
self.assertLessEqual(clock[0], 1.1, 'one-second deadline took %.1f seconds' % clock[0])
|
||||||
|
|
||||||
|
def test_tool_exception_sets_result_iserror(self):
|
||||||
|
p = Peer()
|
||||||
|
try:
|
||||||
|
r = p.send({'jsonrpc': '2.0', 'id': 1, 'method': 'tools/call',
|
||||||
|
'params': {'name': 'move', 'arguments': {'x': 'invalid', 'y': 1}}})
|
||||||
|
self.assertTrue(r['result'].get('isError', False), r)
|
||||||
|
finally:
|
||||||
|
p.close()
|
||||||
|
|
||||||
|
def test_unknown_tool_returns_protocol_error(self):
|
||||||
|
p = Peer()
|
||||||
|
try:
|
||||||
|
r = p.send({'jsonrpc': '2.0', 'id': 1, 'method': 'tools/call',
|
||||||
|
'params': {'name': 'unknown', 'arguments': {}}})
|
||||||
|
self.assertIn('error', r, r)
|
||||||
|
finally:
|
||||||
|
p.close()
|
||||||
|
|
||||||
|
def test_invalid_json_keeps_server_alive(self):
|
||||||
|
p = Peer()
|
||||||
|
try:
|
||||||
|
p.p.stdin.write('{ invalid json }\n')
|
||||||
|
p.p.stdin.flush()
|
||||||
|
line = p.q.get(timeout=5)
|
||||||
|
self.assertIsNotNone(line, 'server closes stdout and exits without JSON-RPC parse error')
|
||||||
|
self.assertEqual(json.loads(line)['error']['code'], -32700)
|
||||||
|
finally:
|
||||||
|
p.close()
|
||||||
|
|
||||||
|
def test_sendinput_failed_injection_is_reported(self):
|
||||||
|
from backends.sendinput_win import SendInputBackend
|
||||||
|
b = SendInputBackend.__new__(SendInputBackend)
|
||||||
|
with patch.object(b, '_send_input', return_value=0):
|
||||||
|
r = b.keypress('p')
|
||||||
|
self.assertFalse(r['ok'], r)
|
||||||
|
|
||||||
|
def test_uinput_key_constants_in_scope(self):
|
||||||
|
from backends.uinput_linux import UinputBackend
|
||||||
|
b = UinputBackend.__new__(UinputBackend)
|
||||||
|
with patch.object(b, '_key'):
|
||||||
|
r = b.keypress('enter')
|
||||||
|
self.assertTrue(r['ok'])
|
||||||
|
|
||||||
|
def test_uinput_device_events_are_valid(self):
|
||||||
|
import types
|
||||||
|
from backends.uinput_linux import UinputBackend
|
||||||
|
fake = types.SimpleNamespace(Device=lambda events: object())
|
||||||
|
names = ['KEY_A', 'KEY_Z', 'KEY_ENTER', 'KEY_ESC', 'KEY_SPACE', 'KEY_TAB', 'KEY_F4',
|
||||||
|
'KEY_LEFTCTRL', 'KEY_LEFTSHIFT', 'KEY_LEFTALT', 'KEY_BACKSPACE',
|
||||||
|
'REL_X', 'REL_Y', 'BTN_LEFT', 'BTN_RIGHT']
|
||||||
|
for i, name in enumerate(names):
|
||||||
|
setattr(fake, name, (1, i + 30))
|
||||||
|
b = UinputBackend.__new__(UinputBackend)
|
||||||
|
b._ctx = None
|
||||||
|
with patch.dict(sys.modules, {'uinput': fake}):
|
||||||
|
self.assertIsNotNone(b._ensure())
|
||||||
|
|
||||||
|
|
||||||
|
class Result(unittest.TextTestResult):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.records = []
|
||||||
|
|
||||||
|
def addSuccess(self, test):
|
||||||
|
super().addSuccess(test)
|
||||||
|
self.records.append({'test': test.id(), 'status': 'PASS'})
|
||||||
|
|
||||||
|
def addFailure(self, test, err):
|
||||||
|
super().addFailure(test, err)
|
||||||
|
self.records.append({'test': test.id(), 'status': 'FAIL', 'detail': self._exc_info_to_string(err, test)})
|
||||||
|
|
||||||
|
def addError(self, test, err):
|
||||||
|
super().addError(test, err)
|
||||||
|
self.records.append({'test': test.id(), 'status': 'ERROR', 'detail': self._exc_info_to_string(err, test)})
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
suite = unittest.defaultTestLoader.loadTestsFromModule(sys.modules[__name__])
|
||||||
|
result = unittest.TextTestRunner(verbosity=2, resultclass=Result).run(suite)
|
||||||
|
(ROOT / 'validation-results.json').write_text(json.dumps(result.records, ensure_ascii=False, indent=2), encoding='utf-8')
|
||||||
|
sys.exit(0 if result.wasSuccessful() else 1)
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1 @@
|
|||||||
|
CreateObject("WScript.Shell").Run "powershell.exe -NoProfile -ExecutionPolicy Bypass -File "D:\codex\tmp\lc-mcp-test\validation-artifacts\nonexistent-test-job.ps1"", 0, False
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
test_click_text_second_hit (__main__.HealthyPaths) ... ok
|
||||||
|
test_get_state (__main__.HealthyPaths) ... ok
|
||||||
|
test_missing_text_does_not_click (__main__.HealthyPaths) ... ok
|
||||||
|
test_ocr_confidence_filter (__main__.HealthyPaths) ... ok
|
||||||
|
test_ocr_error_does_not_click (__main__.HealthyPaths) ... ok
|
||||||
|
test_protocol_discovery_and_all_input_tools (__main__.HealthyPaths) ... ok
|
||||||
|
test_screenshot_error_propagates (__main__.HealthyPaths) ... ok
|
||||||
|
test_substring_case_insensitive (__main__.HealthyPaths) ... ok
|
||||||
|
test_text_coordinates (__main__.HealthyPaths) ... ok
|
||||||
|
test_wait_absent (__main__.HealthyPaths) ... ok
|
||||||
|
test_wait_present (__main__.HealthyPaths) ... ok
|
||||||
|
test_invalid_json_keeps_server_alive (__main__.RequiredBehavior) ... FAIL
|
||||||
|
test_missing_click_coordinates_rejected (__main__.RequiredBehavior) ... FAIL
|
||||||
|
test_missing_click_text_rejected (__main__.RequiredBehavior) ... FAIL
|
||||||
|
test_negative_index_rejected (__main__.RequiredBehavior) ... FAIL
|
||||||
|
test_out_of_range_index_rejected (__main__.RequiredBehavior) ... FAIL
|
||||||
|
test_sendinput_failed_injection_is_reported (__main__.RequiredBehavior) ... FAIL
|
||||||
|
test_tool_exception_sets_result_iserror (__main__.RequiredBehavior) ... FAIL
|
||||||
|
test_uinput_device_events_are_valid (__main__.RequiredBehavior) ... ERROR
|
||||||
|
test_uinput_key_constants_in_scope (__main__.RequiredBehavior) ... ERROR
|
||||||
|
test_unknown_tool_returns_protocol_error (__main__.RequiredBehavior) ... FAIL
|
||||||
|
test_wait_timeout_honored (__main__.RequiredBehavior) ... FAIL
|
||||||
|
|
||||||
|
======================================================================
|
||||||
|
ERROR: test_uinput_device_events_are_valid (__main__.RequiredBehavior)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "tests\test_validation.py", line 226, in test_uinput_device_events_are_valid
|
||||||
|
self.assertIsNotNone(b._ensure())
|
||||||
|
File "D:\codex\tmp\lc-mcp-test\backends\uinput_linux.py", line 28, in _ensure
|
||||||
|
*[key for key in range(KEY_A, KEY_Z + 1)],
|
||||||
|
TypeError: can only concatenate tuple (not "int") to tuple
|
||||||
|
|
||||||
|
======================================================================
|
||||||
|
ERROR: test_uinput_key_constants_in_scope (__main__.RequiredBehavior)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "tests\test_validation.py", line 211, in test_uinput_key_constants_in_scope
|
||||||
|
r = b.keypress('enter')
|
||||||
|
File "D:\codex\tmp\lc-mcp-test\backends\uinput_linux.py", line 72, in keypress
|
||||||
|
mapping = {'enter': KEY_ENTER, 'esc': KEY_ESC, 'space': KEY_SPACE,
|
||||||
|
NameError: name 'KEY_ENTER' is not defined
|
||||||
|
|
||||||
|
======================================================================
|
||||||
|
FAIL: test_invalid_json_keeps_server_alive (__main__.RequiredBehavior)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "tests\test_validation.py", line 195, in test_invalid_json_keeps_server_alive
|
||||||
|
self.assertIsNotNone(line, 'server closes stdout and exits without JSON-RPC parse error')
|
||||||
|
AssertionError: unexpectedly None : server closes stdout and exits without JSON-RPC parse error
|
||||||
|
|
||||||
|
======================================================================
|
||||||
|
FAIL: test_missing_click_coordinates_rejected (__main__.RequiredBehavior)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "tests\test_validation.py", line 139, in test_missing_click_coordinates_rejected
|
||||||
|
self.assertFalse(result['ok'], result)
|
||||||
|
AssertionError: True is not false : {'ok': True, 'clicked': [0, 0], 'backend': 'mock'}
|
||||||
|
|
||||||
|
======================================================================
|
||||||
|
FAIL: test_missing_click_text_rejected (__main__.RequiredBehavior)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "tests\test_validation.py", line 145, in test_missing_click_text_rejected
|
||||||
|
self.assertFalse(result['ok'], result)
|
||||||
|
AssertionError: True is not false : {'ok': True, 'clicked': [140, 220], 'backend': 'mock', 'on': '��ʼ'}
|
||||||
|
|
||||||
|
======================================================================
|
||||||
|
FAIL: test_negative_index_rejected (__main__.RequiredBehavior)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "tests\test_validation.py", line 156, in test_negative_index_rejected
|
||||||
|
self.assertFalse(result['ok'], result)
|
||||||
|
AssertionError: True is not false : {'ok': True, 'clicked': [350, 425], 'backend': 'mock', 'on': '��ʼս��'}
|
||||||
|
|
||||||
|
======================================================================
|
||||||
|
FAIL: test_out_of_range_index_rejected (__main__.RequiredBehavior)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "tests\test_validation.py", line 151, in test_out_of_range_index_rejected
|
||||||
|
self.assertFalse(result['ok'], result)
|
||||||
|
AssertionError: True is not false : {'ok': True, 'clicked': [350, 425], 'backend': 'mock', 'on': '��ʼս��'}
|
||||||
|
|
||||||
|
======================================================================
|
||||||
|
FAIL: test_sendinput_failed_injection_is_reported (__main__.RequiredBehavior)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "tests\test_validation.py", line 205, in test_sendinput_failed_injection_is_reported
|
||||||
|
self.assertFalse(r['ok'], r)
|
||||||
|
AssertionError: True is not false : {'ok': True, 'key': 'p', 'backend': 'sendinput'}
|
||||||
|
|
||||||
|
======================================================================
|
||||||
|
FAIL: test_tool_exception_sets_result_iserror (__main__.RequiredBehavior)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "tests\test_validation.py", line 176, in test_tool_exception_sets_result_iserror
|
||||||
|
self.assertTrue(r['result'].get('isError', False), r)
|
||||||
|
AssertionError: False is not true : {'jsonrpc': '2.0', 'id': 1, 'result': {'content': [{'type': 'text', 'text': '{"ok": false, "error": "invalid literal for int() with base 10: \'invalid\'"}'}]}, 'isError': True}
|
||||||
|
|
||||||
|
======================================================================
|
||||||
|
FAIL: test_unknown_tool_returns_protocol_error (__main__.RequiredBehavior)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "tests\test_validation.py", line 185, in test_unknown_tool_returns_protocol_error
|
||||||
|
self.assertIn('error', r, r)
|
||||||
|
AssertionError: 'error' not found in {'jsonrpc': '2.0', 'id': 1, 'result': {'content': [{'type': 'text', 'text': '{"ok": false, "error": "unknown tool unknown"}'}]}} : {'jsonrpc': '2.0', 'id': 1, 'result': {'content': [{'type': 'text', 'text': '{"ok": false, "error": "unknown tool unknown"}'}]}}
|
||||||
|
|
||||||
|
======================================================================
|
||||||
|
FAIL: test_wait_timeout_honored (__main__.RequiredBehavior)
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "tests\test_validation.py", line 169, in test_wait_timeout_honored
|
||||||
|
self.assertLessEqual(clock[0], 1.1, 'one-second deadline took %.1f seconds' % clock[0])
|
||||||
|
AssertionError: 31.2 not less than or equal to 1.1 : one-second deadline took 31.2 seconds
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Ran 22 tests in 0.886s
|
||||||
|
|
||||||
|
FAILED (failures=9, errors=2)
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"test": "__main__.HealthyPaths.test_click_text_second_hit",
|
||||||
|
"status": "PASS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.HealthyPaths.test_get_state",
|
||||||
|
"status": "PASS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.HealthyPaths.test_missing_text_does_not_click",
|
||||||
|
"status": "PASS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.HealthyPaths.test_ocr_confidence_filter",
|
||||||
|
"status": "PASS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.HealthyPaths.test_ocr_error_does_not_click",
|
||||||
|
"status": "PASS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.HealthyPaths.test_protocol_discovery_and_all_input_tools",
|
||||||
|
"status": "PASS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.HealthyPaths.test_screenshot_error_propagates",
|
||||||
|
"status": "PASS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.HealthyPaths.test_substring_case_insensitive",
|
||||||
|
"status": "PASS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.HealthyPaths.test_text_coordinates",
|
||||||
|
"status": "PASS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.HealthyPaths.test_wait_absent",
|
||||||
|
"status": "PASS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.HealthyPaths.test_wait_present",
|
||||||
|
"status": "PASS"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.RequiredBehavior.test_invalid_json_keeps_server_alive",
|
||||||
|
"status": "FAIL",
|
||||||
|
"detail": "Traceback (most recent call last):\n File \"tests\\test_validation.py\", line 195, in test_invalid_json_keeps_server_alive\n self.assertIsNotNone(line, 'server closes stdout and exits without JSON-RPC parse error')\nAssertionError: unexpectedly None : server closes stdout and exits without JSON-RPC parse error\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.RequiredBehavior.test_missing_click_coordinates_rejected",
|
||||||
|
"status": "FAIL",
|
||||||
|
"detail": "Traceback (most recent call last):\n File \"tests\\test_validation.py\", line 139, in test_missing_click_coordinates_rejected\n self.assertFalse(result['ok'], result)\nAssertionError: True is not false : {'ok': True, 'clicked': [0, 0], 'backend': 'mock'}\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.RequiredBehavior.test_missing_click_text_rejected",
|
||||||
|
"status": "FAIL",
|
||||||
|
"detail": "Traceback (most recent call last):\n File \"tests\\test_validation.py\", line 145, in test_missing_click_text_rejected\n self.assertFalse(result['ok'], result)\nAssertionError: True is not false : {'ok': True, 'clicked': [140, 220], 'backend': 'mock', 'on': '开始'}\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.RequiredBehavior.test_negative_index_rejected",
|
||||||
|
"status": "FAIL",
|
||||||
|
"detail": "Traceback (most recent call last):\n File \"tests\\test_validation.py\", line 156, in test_negative_index_rejected\n self.assertFalse(result['ok'], result)\nAssertionError: True is not false : {'ok': True, 'clicked': [350, 425], 'backend': 'mock', 'on': '开始战斗'}\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.RequiredBehavior.test_out_of_range_index_rejected",
|
||||||
|
"status": "FAIL",
|
||||||
|
"detail": "Traceback (most recent call last):\n File \"tests\\test_validation.py\", line 151, in test_out_of_range_index_rejected\n self.assertFalse(result['ok'], result)\nAssertionError: True is not false : {'ok': True, 'clicked': [350, 425], 'backend': 'mock', 'on': '开始战斗'}\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.RequiredBehavior.test_sendinput_failed_injection_is_reported",
|
||||||
|
"status": "FAIL",
|
||||||
|
"detail": "Traceback (most recent call last):\n File \"tests\\test_validation.py\", line 205, in test_sendinput_failed_injection_is_reported\n self.assertFalse(r['ok'], r)\nAssertionError: True is not false : {'ok': True, 'key': 'p', 'backend': 'sendinput'}\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.RequiredBehavior.test_tool_exception_sets_result_iserror",
|
||||||
|
"status": "FAIL",
|
||||||
|
"detail": "Traceback (most recent call last):\n File \"tests\\test_validation.py\", line 176, in test_tool_exception_sets_result_iserror\n self.assertTrue(r['result'].get('isError', False), r)\nAssertionError: False is not true : {'jsonrpc': '2.0', 'id': 1, 'result': {'content': [{'type': 'text', 'text': '{\"ok\": false, \"error\": \"invalid literal for int() with base 10: \\'invalid\\'\"}'}]}, 'isError': True}\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.RequiredBehavior.test_uinput_device_events_are_valid",
|
||||||
|
"status": "ERROR",
|
||||||
|
"detail": "Traceback (most recent call last):\n File \"tests\\test_validation.py\", line 226, in test_uinput_device_events_are_valid\n self.assertIsNotNone(b._ensure())\n File \"D:\\codex\\tmp\\lc-mcp-test\\backends\\uinput_linux.py\", line 28, in _ensure\n *[key for key in range(KEY_A, KEY_Z + 1)],\nTypeError: can only concatenate tuple (not \"int\") to tuple\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.RequiredBehavior.test_uinput_key_constants_in_scope",
|
||||||
|
"status": "ERROR",
|
||||||
|
"detail": "Traceback (most recent call last):\n File \"tests\\test_validation.py\", line 211, in test_uinput_key_constants_in_scope\n r = b.keypress('enter')\n File \"D:\\codex\\tmp\\lc-mcp-test\\backends\\uinput_linux.py\", line 72, in keypress\n mapping = {'enter': KEY_ENTER, 'esc': KEY_ESC, 'space': KEY_SPACE,\nNameError: name 'KEY_ENTER' is not defined\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.RequiredBehavior.test_unknown_tool_returns_protocol_error",
|
||||||
|
"status": "FAIL",
|
||||||
|
"detail": "Traceback (most recent call last):\n File \"tests\\test_validation.py\", line 185, in test_unknown_tool_returns_protocol_error\n self.assertIn('error', r, r)\nAssertionError: 'error' not found in {'jsonrpc': '2.0', 'id': 1, 'result': {'content': [{'type': 'text', 'text': '{\"ok\": false, \"error\": \"unknown tool unknown\"}'}]}} : {'jsonrpc': '2.0', 'id': 1, 'result': {'content': [{'type': 'text', 'text': '{\"ok\": false, \"error\": \"unknown tool unknown\"}'}]}}\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "__main__.RequiredBehavior.test_wait_timeout_honored",
|
||||||
|
"status": "FAIL",
|
||||||
|
"detail": "Traceback (most recent call last):\n File \"tests\\test_validation.py\", line 169, in test_wait_timeout_honored\n self.assertLessEqual(clock[0], 1.1, 'one-second deadline took %.1f seconds' % clock[0])\nAssertionError: 31.2 not less than or equal to 1.1 : one-second deadline took 31.2 seconds\n"
|
||||||
|
}
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user