-
Notifications
You must be signed in to change notification settings - Fork 3k
test(core): close the deferred test gaps recorded in #9930's review rounds #10465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wenshao
merged 4 commits into
QwenLM:main
from
tomsen02:test/debug-log-routing-deferred-gaps
Sep 1, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cef2d56
test(core): close the deferred test gaps recorded in #9930's review r…
tomsen02 36e3749
test(core): extract shared debug-fallback isolation helper (round-1 R…
tomsen02 159611a
test(core): fix TS2345 in withDebugFallbackIsolation (round-2 R1-1)
tomsen02 a6cab44
docs(cli): point the drain's no-exit comment at the choke point (roun…
tomsen02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Critical] R1-1: (fix-induced) [fails-closed] [regression] The new
withDebugFallbackIsolationhelper types its callback asReturnType<typeof vi.spyOn>, which resolves to vitest's generic-constraint overloadMockInstance<(this: unknown, ...args: unknown[]) => unknown>— the concretevi.spyOn(fs.promises, 'appendFile')spy is not assignable to it, sonpm run build --workspace=packages/corefails with TS2345. The round-1 fix for R1-1 (extracting this shared helper) introduced it: every build or typecheck of packages/core — the CITestjob,npm run typecheck,npm run preflight, and dependent workspaces — exits non-zero atsrc/config/config.test.ts(650,17)onawait run(appendFileSpy);. vitest transpiles without type-checking, so the two tests still run green and the failure is invisible to a test-only run; live CI on this commit is red with exactly this error.Witness:
Fix (two spots — repo precedent at
packages/core/src/services/sessionService.test.ts:74):The annotation must stay assignable where the spy is passed —
await run(appendFileSpy)at config.test.ts:650, with the spy produced asvi.spyOn(fs.promises, 'appendFile').mockResolvedValue(undefined)(config.test.ts:637-639) and consumed in both test bodies viatoHaveBeenCalledWith(path, expect.stringContaining(...), 'utf8')— so it must not be widened to a bareMock/vi.fn()type that drops the call-argument typing.Acceptance criterion:
npm run build --workspace=packages/coremust go green — it is red today with TS2345 at config.test.ts:650, and reverting the annotation toReturnType<typeof vi.spyOn>reproduces the failure (no runtime test pins a type annotation, so the build itself is the mutation check).中文说明
R1-1:(修复引入)新的
withDebugFallbackIsolation辅助函数把回调参数标注为ReturnType<typeof vi.spyOn>,它解析到 vitest 的泛型约束重载MockInstance<(this: unknown, ...args: unknown[]) => unknown>—— 具体的vi.spyOn(fs.promises, 'appendFile')spy 无法赋给该类型,导致npm run build --workspace=packages/core报 TS2345 失败。本缺陷由第 1 轮 R1-1 的修复(提取这个共享辅助函数)引入:所有对 packages/core 的构建或类型检查 —— CI 的Test任务、npm run typecheck、npm run preflight、以及依赖它的工作区 —— 都会在src/config/config.test.ts(650,17)的await run(appendFileSpy);处非零退出。vitest 转译时不做类型检查,所以这两个测试仍然绿灯,仅跑测试看不到该失败;当前提交上的 CI 正是因为这个错误而红。修复(两处 —— 仓库先例见
packages/core/src/services/sessionService.test.ts:74):把类型导入扩展为import type { Mock, MockInstance } from 'vitest';,并把辅助函数签名改为run: (appendFileSpy: MockInstance<typeof fs.promises.appendFile>) => Promise<void>。约束:该标注必须保持可赋值 ——
await run(appendFileSpy)(config.test.ts:650)处的 spy 由vi.spyOn(fs.promises, 'appendFile').mockResolvedValue(undefined)(config.test.ts:637-639)产生,并被两个测试体以toHaveBeenCalledWith(path, expect.stringContaining(...), 'utf8')消费 —— 因此不能放宽为丢失调用参数类型的裸Mock/vi.fn()类型。验收标准:
npm run build --workspace=packages/core必须变绿 —— 当前因 config.test.ts:650 的 TS2345 而红,把标注还原为ReturnType<typeof vi.spyOn>会复现该失败(类型标注没有运行时测试可钉,构建本身就是变异检验)。— qwen3.8-max via Qwen Code /review (v0.22.3)