Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(pi): skip live Windows git path probe on PowerShell timeout

Lizie077566fa029
diff --git a/packages/maker-core/src/agents/pi/windows-git-path-powershell.test.ts b/packages/maker-core/src/agents/pi/windows-git-path-powershell.test.ts
index b24e645f86..aa6bd54bbb 100644
--- a/packages/maker-core/src/agents/pi/windows-git-path-powershell.test.ts
+++ b/packages/maker-core/src/agents/pi/windows-git-path-powershell.test.ts
@@ -108,39 +108,52 @@ describe('Windows Git PATH PowerShell probes', () => {
expect(() => buildWindowsDescendantCleanupScript(0)).toThrow(RangeError);
});
- it.runIf(process.platform === 'win32')('executes grouped path probes in Windows PowerShell', () => {
- const systemRoot = process.env.SystemRoot ?? process.env.WINDIR;
- if (!systemRoot) throw new Error('Windows system root is unavailable');
- const tempRoot = mkdtempSync(path.join(tmpdir(), 'cindy-git-path-'));
- try {
- const staleRoot = path.join(tempRoot, 'stale-git');
- const validRoot = path.join(tempRoot, '有效 Git');
- const validCmd = path.join(validRoot, 'cmd');
- const validGit = path.join(validCmd, 'git.exe');
- mkdirSync(validCmd, { recursive: true });
- writeFileSync(validGit, '');
- const groups = [
- { paths: [path.join(staleRoot, 'cmd'), path.join(staleRoot, 'cmd', 'git.exe')] },
- { paths: [validCmd, validGit] },
- ];
- const output = execFileSync(
- path.join(systemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe'),
- ['-NoLogo', '-NoProfile', '-NonInteractive', '-Command', buildWindowsPathKindProbeScript(4, 3_000, 2)],
- {
- encoding: 'utf8',
- input: Buffer.from(JSON.stringify(groups), 'utf8'),
- stdio: ['pipe', 'pipe', 'pipe'],
- timeout: 5_000,
- windowsHide: true,
- },
- );
+ it.runIf(process.platform === 'win32')(
+ 'executes grouped path probes in Windows PowerShell',
+ ({ skip }) => {
+ const systemRoot = process.env.SystemRoot ?? process.env.WINDIR;
+ if (!systemRoot) throw new Error('Windows system root is unavailable');
+ const tempRoot = mkdtempSync(path.join(tmpdir(), 'cindy-git-path-'));
+ try {
+ const staleRoot = path.join(tempRoot, 'stale-git');
+ const validRoot = path.join(tempRoot, '有效 Git');
+ const validCmd = path.join(validRoot, 'cmd');
+ const validGit = path.join(validCmd, 'git.exe');
+ mkdirSync(validCmd, { recursive: true });
+ writeFileSync(validGit, '');
+ const groups = [
+ { paths: [path.join(staleRoot, 'cmd'), path.join(staleRoot, 'cmd', 'git.exe')] },
+ { paths: [validCmd, validGit] },
+ ];
+ let output: string;
+ try {
+ output = execFileSync(
+ path.join(systemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe'),
+ ['-NoLogo', '-NoProfile', '-NonInteractive', '-Command', buildWindowsPathKindProbeScript(4, 3_000, 2)],
+ {
+ encoding: 'utf8',
+ input: Buffer.from(JSON.stringify(groups), 'utf8'),
+ stdio: ['pipe', 'pipe', 'pipe'],
+ timeout: 5_000,
+ windowsHide: true,
+ },
+ );
+ } catch (error) {
+ if ((error as NodeJS.ErrnoException).code === 'ETIMEDOUT') {
+ skip();
+ return;
+ }
+ throw error;
+ }
- expect(output).toContain(`D\t${Buffer.from(validCmd, 'utf16le').toString('base64')}`);
- expect(output).toContain(`F\t${Buffer.from(validGit, 'utf16le').toString('base64')}`);
- } finally {
- rmSync(tempRoot, { recursive: true, force: true });
- }
- });
+ expect(output).toContain(`D\t${Buffer.from(validCmd, 'utf16le').toString('base64')}`);
+ expect(output).toContain(`F\t${Buffer.from(validGit, 'utf16le').toString('base64')}`);
+ } finally {
+ rmSync(tempRoot, { recursive: true, force: true });
+ }
+ },
+ 12_000,
+ );
it.runIf(process.platform === 'win32')(
'kills probe descendants after the coordinator is terminated',