Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
ts 34 lines 1.21 KB
Raw
1 import { describe, expect, layer } from '@effect/vitest';
2 import * as BunServices from '@effect/platform-bun/BunServices';
3 import { Effect } from 'effect';
4 import { ChildProcess } from 'effect/process';
5 import { childExitStatus } from 'src/effects/child-exit-status';
6
7 // Runs real children through the installed spawner, so an Effect upgrade that changes how it
8 // reports a child a signal ended fails here instead of silently breaking `composio run`.
9 const statusOf = (script: string) =>
10 ChildProcess.make(process.execPath, ['-e', script]).pipe(
11 Effect.flatMap(childExitStatus),
12 Effect.scoped
13 );
14
15 describe('childExitStatus', () => {
16 layer(BunServices.layer)(it => {
17 it.effect('[Given] a child that exits [Then] reports its code', () =>
18 Effect.gen(function* () {
19 expect(yield* statusOf('process.exit(3)')).toEqual({ code: 3, signal: null });
20 })
21 );
22
23 it.effect.each(['SIGINT', 'SIGTERM', 'SIGKILL'] as const)(
24 '[Given] a child %s ends [Then] reports the signal',
25 signal =>
26 Effect.gen(function* () {
27 expect(yield* statusOf(`process.kill(process.pid, '${signal}')`)).toEqual({
28 code: null,
29 signal,
30 });
31 })
32 );
33 });
34 });