From d71aa8df86c1d551d0a5178d710826fb950b84ff Mon Sep 17 00:00:00 2001 From: Dudu-0223 Date: Mon, 9 Nov 2026 17:15:43 +0800 Subject: [PATCH 1/2] test(plugin-manager): preserve observed Git timeout status --- .../tests/github-connection.spec.ts | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/boot/plugin-manager/tests/github-connection.spec.ts b/packages/boot/plugin-manager/tests/github-connection.spec.ts index 1d76e1eaf1..d7e66946d6 100644 --- a/packages/boot/plugin-manager/tests/github-connection.spec.ts +++ b/packages/boot/plugin-manager/tests/github-connection.spec.ts @@ -118,8 +118,12 @@ it('ends a silent proxy connection and its Git child at the connection deadline' await transport.connected const result = await running expect(result?.kind).toBe('timeout') - // The result records the status the terminated Git is read as; only the streamed run reports no exit code. - expect(result).toMatchObject({ exitCode: 1, timedOut: true, argv: checkArgv('https://github.com/acme/plugin.git') }) + // Git's termination status varies by platform; preserve the observed status, or the fallback when absent. + const childResult = await vi.mocked(subprocess.execa).mock.results.at(-1)!.value + expect(childResult.timedOut).toBe(true) + expect(result).toMatchObject({ + exitCode: childResult.exitCode ?? 1, timedOut: true, argv: checkArgv('https://github.com/acme/plugin.git'), + }) expect(result!.output).toContain('connection to github.com timed out after 3000ms') await transport.disconnected expect(transport.sockets.size).toBe(0) @@ -137,6 +141,18 @@ it('cancels a connected Git probe and closes its transport before the deadline', expect(transport.sockets.size).toBe(0) }) +it.each([128, undefined])('reports a timeout while retaining Git exit status %s', async (exitCode) => { + const { check } = await fixture() + const run = vi.spyOn(subprocess, 'execa').mockResolvedValue({ + failed: true, timedOut: true, exitCode, + } as Awaited>) + onTestFinished(() => { run.mockRestore() }) + const result = await check('github:acme/plugin') + expect(result).toMatchObject({ exitCode: exitCode ?? 1, timedOut: true, kind: 'timeout' }) + expect(result!.output).toContain('connection to github.com timed out after 3000ms') + expect(await readFile(result!.logPath, 'utf8')).toBe(result!.output) +}) + it.each([undefined, 'Git could not start'])('retains a diagnostic when Git writes no stderr (%s)', async (shortMessage) => { const { check } = await fixture() const run = vi.spyOn(subprocess, 'execa').mockResolvedValue({ failed: true, shortMessage } as Awaited>) From ab3e2e7db8dfcc989f70cf355b34a11846d0ab4e Mon Sep 17 00:00:00 2001 From: Dudu-0223 Date: Mon, 9 Nov 2026 17:22:56 +0800 Subject: [PATCH 2/2] test(plugin-manager): narrow recorded Git invocation result --- packages/boot/plugin-manager/tests/github-connection.spec.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/boot/plugin-manager/tests/github-connection.spec.ts b/packages/boot/plugin-manager/tests/github-connection.spec.ts index d7e66946d6..d1d292fc2c 100644 --- a/packages/boot/plugin-manager/tests/github-connection.spec.ts +++ b/packages/boot/plugin-manager/tests/github-connection.spec.ts @@ -119,7 +119,9 @@ it('ends a silent proxy connection and its Git child at the connection deadline' const result = await running expect(result?.kind).toBe('timeout') // Git's termination status varies by platform; preserve the observed status, or the fallback when absent. - const childResult = await vi.mocked(subprocess.execa).mock.results.at(-1)!.value + const childRun = vi.mocked(subprocess.execa).mock.results.at(-1) + if (childRun?.type !== 'return') throw new Error('Git probe did not return a child process') + const childResult = await childRun.value expect(childResult.timedOut).toBe(true) expect(result).toMatchObject({ exitCode: childResult.exitCode ?? 1, timedOut: true, argv: checkArgv('https://github.com/acme/plugin.git'),