diff --git a/apps/ai-game-creator-shell/tests/agentSwarmTestEntry.test.ts b/apps/ai-game-creator-shell/tests/agentSwarmTestEntry.test.ts index 99418c563..e0c69cd78 100644 --- a/apps/ai-game-creator-shell/tests/agentSwarmTestEntry.test.ts +++ b/apps/ai-game-creator-shell/tests/agentSwarmTestEntry.test.ts @@ -72,6 +72,11 @@ import { const appRoot = path.resolve(fileURLToPath(new URL('..', import.meta.url))); +// Windows 下「私有路径加固」每次都会拉起真实 powershell.exe 去设置 DACL(本机实测约 0.6 秒 / 次)。 +// 只校验配置分层、隔离与清理语义的用例统一传入这份 no-op 桩;真正覆盖私有 ACL 的用例才走真实实现。 +const skippedWindowsAclOptions = + process.platform === 'win32' ? { secureWindowsPath: async () => {} } : {}; + async function withTemporaryRoot( run: (root: string) => Promise, ): Promise { @@ -552,11 +557,19 @@ describe('terminal configuration wizard persistence', () => { }; await expect( - writeGameCreatorConfigAtomically(configPath, firstConfig), + writeGameCreatorConfigAtomically( + configPath, + firstConfig, + skippedWindowsAclOptions, + ), ).resolves.toBe(configPath); const firstMetadata = await lstat(configPath); await expect( - writeGameCreatorConfigAtomically(configPath, finalConfig), + writeGameCreatorConfigAtomically( + configPath, + finalConfig, + skippedWindowsAclOptions, + ), ).resolves.toBe(configPath); const [directoryMetadata, finalMetadata, entries, contents] = @@ -584,13 +597,6 @@ describe('terminal configuration wizard persistence', () => { it('moves the default LLM to primary config and lets later GUI saves win', async () => { await withTemporaryRoot(async (root) => { - // 读写都要带上这个桩:读路径同样会加固私有目录与配置文件, - // 在 Windows 上每次加固都要拉起一个 powershell.exe(约 0.6 秒), - // 本用例只校验配置分层优先级,不该为无关的 DACL 子进程耗掉超时预算。 - const persistenceOptions = - process.platform === 'win32' - ? { secureWindowsPath: async () => {} } - : {}; const configDir = path.join(root, appIdentifier); const primaryPath = path.join(configDir, configFileName); const localPath = path.join(configDir, localConfigFileName); @@ -606,7 +612,7 @@ describe('terminal configuration wizard persistence', () => { const state = await readGameCreatorWizardConfigState( configDir, - persistenceOptions, + skippedWindowsAclOptions, ); expect(state.configPath).toBe(primaryPath); expect(state.effectiveConfig.llm.model).toBe('stale-local'); @@ -619,7 +625,7 @@ describe('terminal configuration wizard persistence', () => { await writeGameCreatorWizardConfig( state, wizardConfig, - persistenceOptions, + skippedWindowsAclOptions, ); const sanitizedLocal = JSON.parse(await readFile(localPath, 'utf8')); @@ -627,7 +633,7 @@ describe('terminal configuration wizard persistence', () => { expect(sanitizedLocal.agentLlm.planner.model).toBe('planner'); const afterWizard = await readGameCreatorWizardConfigState( configDir, - persistenceOptions, + skippedWindowsAclOptions, ); expect(afterWizard.effectiveConfig.llm).toMatchObject({ apiKey: 'wizard-key', @@ -645,11 +651,11 @@ describe('terminal configuration wizard persistence', () => { await writeGameCreatorConfigAtomically( primaryPath, guiConfig, - persistenceOptions, + skippedWindowsAclOptions, ); const afterGui = await readGameCreatorWizardConfigState( configDir, - persistenceOptions, + skippedWindowsAclOptions, ); expect(afterGui.effectiveConfig.llm.apiKey).toBe('gui-key'); expect(afterGui.effectiveConfig.llm.model).toBe('gui-model'); @@ -981,6 +987,7 @@ describe('isolated Swarm runtime config', () => { const runtimeConfig = await prepareSwarmTestRuntimeConfig( sourceConfigDir, root, + skippedWindowsAclOptions, ); const runtimeEntries = (await readdir(runtimeConfig.path)).sort(); const runtimeDirectoryMetadata = await lstat(runtimeConfig.path); @@ -1059,7 +1066,11 @@ describe('isolated Swarm runtime config', () => { ); await expect( - prepareSwarmTestRuntimeConfig(sourceConfigDir, root), + prepareSwarmTestRuntimeConfig( + sourceConfigDir, + root, + skippedWindowsAclOptions, + ), ).rejects.toThrow(localConfigFileName); expect( (await readdir(root)).filter((entry) => @@ -1077,6 +1088,7 @@ describe('isolated Swarm runtime config', () => { const runtimeConfig = await prepareSwarmTestRuntimeConfig( sourceConfigDir, root, + skippedWindowsAclOptions, ); const endpointPath = path.join( runtimeConfig.path,