From f693f742c510d201e1eaf88d6578bd362e7ce898 Mon Sep 17 00:00:00 2001 From: doudouOUC Date: Mon, 18 May 2026 14:00:45 +0800 Subject: [PATCH] fix(serve): skip two Windows-incompatible test fixtures on win32 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both tests rely on `fs.chmod(dir, 0o555)` to trigger EACCES on a subsequent write/unlink. Windows ignores Unix-style permission bits passed to `fs.chmod`, so the directory stays writable, the operation succeeds, and the error path the test exercises is unreachable — the test then sees the success status (200 / 204) instead of the expected 500. CI failed on Windows runner only; Ubuntu + macOS pass. Route logic is platform-agnostic — these tests validate that: - `workspaceMemory.test.ts` POST returns the structured 500 envelope (no `errorMessage` / `filePath` leakage outside QWEN_SERVE_DEBUG). - `workspaceAgents.test.ts` DELETE returns 500 `agent_delete_partial` when one level's `fs.unlink` silently fails inside SubagentManager. Both invariants are still covered by the Ubuntu + macOS runs. We can't swap in a `vi.spyOn(fs, 'unlink')` mock for the agents case either — `SubagentManager` does `import * as fs from 'fs/promises'`, creating a sealed ESM namespace object vitest can't redefine. Skip pattern mirrors `customBanner.test.ts:232` (`if (process.platform === 'win32') return;`). --- packages/cli/src/serve/workspaceAgents.test.ts | 12 ++++++++++++ packages/cli/src/serve/workspaceMemory.test.ts | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/packages/cli/src/serve/workspaceAgents.test.ts b/packages/cli/src/serve/workspaceAgents.test.ts index c12728def..908f68920 100644 --- a/packages/cli/src/serve/workspaceAgents.test.ts +++ b/packages/cli/src/serve/workspaceAgents.test.ts @@ -677,6 +677,18 @@ describe('workspace agents routes', () => { }); it('returns 500 agent_delete_partial when one level unlink silently fails', async () => { + // Windows ignores Unix-style permission bits passed to + // `fs.chmod` — the user-agents directory stays writable, the + // unlink succeeds, and the partial-delete path this test + // exercises is unreachable. SubagentManager's `unlink` import + // (`import * as fs from 'fs/promises'`) creates a sealed + // namespace object that vitest can't `spyOn`, so a per-platform + // mock is also off-limits. The route logic itself is + // platform-agnostic; the Ubuntu + macOS runs cover it. Mirrors + // the `process.platform === 'win32'` early-return idiom used in + // `customBanner.test.ts:232`. + if (process.platform === 'win32') return; + const bridge = buildBridgeStub(); const app = buildApp({ bridge, boundWorkspace: workspace }); diff --git a/packages/cli/src/serve/workspaceMemory.test.ts b/packages/cli/src/serve/workspaceMemory.test.ts index adf49a8f1..eadc2a452 100644 --- a/packages/cli/src/serve/workspaceMemory.test.ts +++ b/packages/cli/src/serve/workspaceMemory.test.ts @@ -384,6 +384,15 @@ describe('workspace memory routes', () => { }); it('omits errorMessage + filePath in 500/413 responses unless QWEN_SERVE_DEBUG is on', async () => { + // Windows ignores Unix-style permission bits passed to + // `fs.chmod` — the directory stays writable, the POST succeeds + // with 200, and the EACCES path this test exercises is + // unreachable. The route logic itself is platform-agnostic; the + // Ubuntu + macOS runs cover it. Mirrors the + // `process.platform === 'win32'` early-return idiom already used + // in `customBanner.test.ts:232`. + if (process.platform === 'win32') return; + // Default: production response carries no `errorMessage` or // `filePath` fields — operators read the daemon stderr log // for the path. Setting QWEN_SERVE_DEBUG=1 enables both.