From c1848a9dc405d332c26fd1504394e474be0f7fa3 Mon Sep 17 00:00:00 2001 From: mesalogo Date: Thu, 10 Sep 2026 07:01:48 +0800 Subject: [PATCH] test: align runtime fixtures across platforms Account for Electron-as-Node when probing the current executable and update the Linux workspace registry scenario to validate the writable handle behavior shipped with remote file management. --- src/agent-daemon/workspace-registry.test.ts | 26 ++++++++++++--------- src/main/agent/runtime-discovery.test.ts | 8 +++++-- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/agent-daemon/workspace-registry.test.ts b/src/agent-daemon/workspace-registry.test.ts index 15aa07d4..6ea889ad 100644 --- a/src/agent-daemon/workspace-registry.test.ts +++ b/src/agent-daemon/workspace-registry.test.ts @@ -137,7 +137,7 @@ describe('WorkspaceRegistry', () => { ).rejects.toMatchObject({ code: 'workspace-not-found' }) }) - linuxIt('enforces read-only policy, caps, and symlink-root rejection', async () => { + linuxIt('supports writable handles while enforcing caps and symlink-root rejection', async () => { const root = temporaryDirectory() const linked = join(tmpdir(), `goodbuddy-linked-${Date.now()}`) symlinkSync(root, linked, 'dir') @@ -149,16 +149,20 @@ describe('WorkspaceRegistry', () => { maximumControllerHandles: 1, inspectGit: async () => 'not-a-repository' }) - await expect( - registry.validate( - { - remoteRootPath: root, - requestedAccess: 'read-write', - requiredCapabilities: [] - }, - controller - ) - ).rejects.toMatchObject({ code: 'read-only' }) + const writable = await registry.validate( + { + remoteRootPath: root, + requestedAccess: 'read-write', + requiredCapabilities: [] + }, + controller + ) + expect(writable.handle.access).toBe('read-write') + await registry.close( + writable.handle.workspaceId, + writable.handle.generation, + controller + ) await expect( registry.validate( { diff --git a/src/main/agent/runtime-discovery.test.ts b/src/main/agent/runtime-discovery.test.ts index 745bae73..c4298a10 100644 --- a/src/main/agent/runtime-discovery.test.ts +++ b/src/main/agent/runtime-discovery.test.ts @@ -75,7 +75,7 @@ describe('runtime discovery', () => { await expect(validation).resolves.toEqual({ valid: false }) }) - it('canonicalizes a configured ordinary file without launching it', async () => { + it('canonicalizes and validates a configured ordinary file first', async () => { process.env.PATH = '' process.env.Path = '' @@ -90,7 +90,11 @@ describe('runtime discovery', () => { path: await realpath(process.execPath), source: 'configured' }) - expect(detection.version).toBeUndefined() + if (process.versions.electron) { + expect(detection.version).toBeUndefined() + } else { + expect(detection.version).toMatch(/^\d+\.\d+\.\d+/u) + } }) it('trusts a configured execution path without reading or launching it', async () => {