test(windows): stabilize native coverage

This commit is contained in:
Tianyi Cui
2026-08-09 02:29:09 +08:00
parent 1ce84853de
commit 94799abfb0
10 changed files with 54 additions and 17 deletions

View File

@@ -156,13 +156,33 @@ const regexEngine = createJavaScriptRegexEngine({
let singleton: HighlighterCore | undefined
/** The synchronous highlighter (one instance per document); pre-warmed below, lazy as the fallback. */
function highlighter(): HighlighterCore {
singleton ??= createHighlighterCoreSync({
/** Representative paths through every boot grammar, compiled before user content is timed. */
const BOOT_GRAMMAR_WARMUPS = [
{ lang: 'typescript', code: 'const answer: number = 42' },
{ lang: 'shellscript', code: 'printf \'%s\\n\' "$HOME"' },
{ lang: 'json', code: '{"ready":true}' },
] as const
/** Construct and pre-tokenize the boot grammars outside the user-content scan budget. */
function createHighlighter(): HighlighterCore {
const instance = createHighlighterCoreSync({
themes: [cssVariablesTheme],
langs: LANGS,
engine: regexEngine,
})
for (const sample of BOOT_GRAMMAR_WARMUPS) {
instance.codeToTokens(sample.code, {
lang: sample.lang,
theme: 'css-variables',
tokenizeTimeLimit: 0,
})
}
return instance
}
/** The synchronous highlighter (one instance per document); pre-warmed below, lazy as the fallback. */
function highlighter(): HighlighterCore {
singleton ??= createHighlighter()
return singleton
}

View File

@@ -416,7 +416,7 @@ describe('dsh-agent-spine-demo bundle', () => {
await ctx.fiber.dispose()
})
it('snapshots a created project skill through catalog refresh and progressive loading', async () => {
it('snapshots a created project skill through catalog refresh and progressive loading', { timeout: 15_000 }, async () => {
const root = await mkdtemp(join(tmpdir(), 'dsh-agent-spine-demo-skill-refresh-'))
const home = await mkdtemp(join(tmpdir(), 'dsh-agent-spine-demo-skill-refresh-home-'))
try {
@@ -449,6 +449,15 @@ describe('dsh-agent-spine-demo bundle', () => {
await ctx.plugin(LocalBashExecutor, {})
await ctx.plugin(LocalFileSystem, { cwd: root })
await ctx.plugin(ToolFs)
ctx.on('tools/post-execute', async (exec, _result, next) => {
const decision = await next()
if (exec.callId === 'write-skill') {
await vi.waitFor(async () => {
expect((await ctx.skills.list({ cwd: root })).map(skill => skill.name)).toContain('hot-skill')
}, { timeout: 5_000 })
}
return decision
})
ctx.llm.registerAdapter(['mock'], adapter)
const handle = await ctx.agents.create({
sessionId: SessionId('skill-refresh-session'),

View File

@@ -109,7 +109,7 @@ async function settleSubagent(
}
describe('HarnessSdkServer', () => {
it('creates a harness agent and calls the configured OpenAI-compatible endpoint', async () => {
it('creates a harness agent and calls the configured OpenAI-compatible endpoint', { timeout: 15_000 }, async () => {
const storageDir = await mkdtemp(join(tmpdir(), 'dsh-jsonrpc-'))
const llmServer = await mockCompletionServer()
vi.stubEnv('DEEPSEEK_API_KEY', 'test-key')
@@ -295,7 +295,7 @@ describe('HarnessSdkServer', () => {
}
})
it('creates an SDK session without an optional system prompt', async () => {
it('creates an SDK session without an optional system prompt', { timeout: 15_000 }, async () => {
const storageDir = await mkdtemp(join(tmpdir(), 'dsh-jsonrpc-no-system-'))
const llmServer = await mockCompletionServer()
vi.stubEnv('DEEPSEEK_API_KEY', 'test-key')