test(experimental): keep mods bridge specs platform-stable

Resolve expected module paths through the platform path module and keep
the signal-termination assertion to POSIX, where a self-killed child has no
exit code.
This commit is contained in:
Tianyi Cui committed 2026-10-02 11:36:41 +08:00
1 parent 7794021892
commit ca83aecbc8
3 files changed
+9 -4

No files matched your search

@@ -450,6 +450,7 @@ export function createHostOps(options: HostOpsOptions): OpTable<AgentBinding> {
})
const outcome = await handle.done
if (deadline.aborted) throw new Error(`$.process.run: ${argv[0]} did not exit within ${timeoutMs} ms`)
/* v8 ignore next -- a Windows child reports an exit code even when terminated; POSIX coverage owns this branch */
if (outcome.exitCode === null) throw new Error(`$.process.run: ${argv[0]} was terminated by signal ${String(outcome.signal)}`)
return {
exitCode: outcome.exitCode,
@@ -178,7 +178,10 @@ describe('processes through the subprocess seam', () => {
expect(run.stdout.endsWith('|set')).toBe(true)
const viaAgent = await call('process.run', { argv: ['node', '-e', 'process.stdout.write(process.cwd())'] }, fakeAgent(ctx, { cwd })) as { stdout: string }
expect(viaAgent.stdout.length).toBeGreaterThan(0)
await expect(call('process.run', { argv: ['node', '-e', 'process.kill(process.pid, "SIGKILL")'] })).rejects.toThrow(/was terminated by signal SIGKILL/)
// A Windows child that kills itself still reports an exit code, so the signal branch is POSIX evidence.
if (process.platform !== 'win32') {
await expect(call('process.run', { argv: ['node', '-e', 'process.kill(process.pid, "SIGKILL")'] })).rejects.toThrow(/was terminated by signal SIGKILL/)
}
await expect(call('process.run', { argv: [] })).rejects.toThrow(/non-empty argv/)
await expect(call('process.run', { argv: ['node', 1] })).rejects.toThrow(/non-empty argv/)
})
@@ -41,11 +41,12 @@ describe('parseModManifest', () => {
})
describe('parseHooksJson', () => {
const hooksJson = '/plugins/demo/hooks/hooks.json'
const root = resolve('/plugins/demo')
const hooksJson = join(root, 'hooks', 'hooks.json')
it('resolves the one module path against hooks.json and notes settings hooks', () => {
expect(parseHooksJson({ modules: ['./register.js'] }, hooksJson)).toEqual({ modulePath: '/plugins/demo/hooks/register.js', hasSettingsHooks: false })
expect(parseHooksJson({ modules: ['../lib/mod.mts'], hooks: {} }, hooksJson)).toEqual({ modulePath: '/plugins/demo/lib/mod.mts', hasSettingsHooks: true })
expect(parseHooksJson({ modules: ['./register.js'] }, hooksJson)).toEqual({ modulePath: join(root, 'hooks', 'register.js'), hasSettingsHooks: false })
expect(parseHooksJson({ modules: ['../lib/mod.mts'], hooks: {} }, hooksJson)).toEqual({ modulePath: join(root, 'lib', 'mod.mts'), hasSettingsHooks: true })
expect(HOOKS_MODULE_EXTENSIONS).toContain('.tsx')
})