Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

AgentScope.test.ts

29 lines1.0 KB

1// @effect-diagnostics nodeBuiltinImport:off
2import * as NodeChildProcess from "node:child_process";
3​
4import { describe, expect, it } from "@effect/vitest";
5​
6import { AGENT_OOM_SCORE_ADJ, agentScopeCommand } from "./AgentScope.ts";
7import * as HostProcess from "./HostProcess.ts";
8​
9describe.skipIf(HostProcess.Platform.defaultValue() !== "linux")("agentScopeCommand", () => {
10 it("raises the OOM score and execs the command with its arguments in the same process", () => {
11 const launch = agentScopeCommand({
12 command: "/bin/sh",
13 args: [
14 "-c",
15 'printf "%s\\n" "$$" "$(cat /proc/self/oom_score_adj)" "$@"',
16 "agent",
17 "a b",
18 "$HOME",
19 ],
20 });
21 const child = NodeChildProcess.spawnSync(launch.command, [...launch.args], {
22 encoding: "utf8",
23 });
24 const [pid, score, ...args] = child.stdout.trimEnd().split("\n");
25 expect(Number(pid)).toBe(child.pid);
26 expect(Number(score)).toBe(AGENT_OOM_SCORE_ADJ);
27 expect(args).toEqual(["a b", "$HOME"]);
28 });
29});