Skip to content

修正状态页线程测试的竞态(合并后 main 上唯一红掉的作业) - #20

Merged
Pau1am merged 1 commit into
mainfrom
fix/status-thread-test-race
Oct 14, 2026
Merged

Pau1am merged 1 commit into
mainfrom
fix/status-thread-test-race

Conversation

@Pau1am

@Pau1am Pau1am commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

改了什么

test_the_status_page_is_built_off_the_command_thread 在 !!muc status 返回后立刻断言「此刻只有一条回复」,而 worker 线程完全可能在这两行之间就把整屏发出去。它在上一个 PR 的分支上是绿的、合并后的 main 上红了——是测试自己的竞态,不是插件的竞态。

现在 worker 由一个事件闸门挡住,直到测试检查完那条回执才放行,断言不再与它抢时间。本机连续跑 6 轮通过。

为什么

合并后的 main(run #42)唯一失败的就是 unit tests (Python 3.10),失败点就是这条断言。留着它会让 main 一直是红的,并且掩盖真正的问题。

如何验证

  • 本机 pytest(含 2 项真实 MCDR 端到端)→ 827 passed
  • 该测试连续重复 6 轮 → 每轮 9 passed(同文件相关用例)
  • ruff check . → 0 项
  • 这个 PR 只改测试文件,不改变产物,因此 v1.6.1 的已发布资产不受影响

`test_the_status_page_is_built_off_the_command_thread` asserted "one reply so
far" immediately after `!!muc status` returned, while the worker thread was free
to finish and post the whole screen in the meantime. It passed on the pull
request and locally, and failed on the merged main — a race in the test, not in
the plugin.

The worker is now held on an event until the acknowledgement has been checked,
so the assertion cannot race it. The test was run repeatedly to confirm.
@Pau1am
Pau1am merged commit fb977b4 into main Oct 14, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant