import { type Resource } from "webappwiz/disposable"; import { FakeChild, FakeTerminalChild } from "./fake-child.js"; import type { ListeningEntry, ProcessEntry, Ps, SpawnCaptureResult, SpawnOptions, SpawnResult, StartOptions, TerminalOptions } from "./ps.js"; export declare class FakePs implements Ps { platform: NodeJS.Platform; pid: number; hostname: string; args: string[]; self: string[]; private dead; private path; private vars; private width; private calls; private dirs; private envs; private handlers; private exitCode; private exited; private captureOutput; private simulation; private children; private terminals; private table; private listeners; /** The pid the next child started gets. */ private nextPid; alive(pid: number): boolean; /** Marks a pid dead, so `alive` reports false for it. */ kill(pid: number): void; spawn(argv: string[], opts?: SpawnOptions): Promise; spawnCapture(argv: string[], opts?: SpawnOptions): Promise; /** A child for the test to play, found again in `getChildren()`. */ start(argv: string[], opts?: StartOptions): FakeChild; /** A terminal child for the test to play, found in `getTerminals()`. */ startOnTerminal(argv: string[], opts: TerminalOptions): FakeTerminalChild; processes(): Promise; listening(): Promise; /** What `listening` lists from now on. */ setListening(listeners: ListeningEntry[]): void; /** What `processes` lists from now on. */ setProcesses(table: ProcessEntry[]): void; cwd(): string; env(name: string): string | undefined; columns(): number | undefined; cd(path: string): void; /** Runs the "exit" handlers on the way out, as a real process does. */ exit(code: number): void; on(signal: string, handler: () => void): Resource; once(event: "exit", handler: () => void): Resource; simulate(simulation: () => Promise): void; setCaptureOutput(stdout: string, stderr: string): void; /** Makes stdout a terminal this many columns wide; undefined, a pipe again. */ setColumns(width: number | undefined): void; setEnv(vars: Record): void; /** The fake starts at `/` unless a test says otherwise. */ setCwd(path: string): void; getCalls(): string[]; /** What `start` started, in order. */ getChildren(): FakeChild[]; /** What `startOnTerminal` started, in order. */ getTerminals(): FakeTerminalChild[]; /** Positionally matched to `getCalls()`. */ getCallDirs(): string[]; /** What each call added to the environment, positionally matched to `getCalls()`. */ getCallEnvs(): Record[]; getExitCode(): number; dispatch(signal: string): void; isExited(): boolean; private off; /** * What a spawn answers with: whatever the simulation returns, or the * process's own code once it has exited, since nothing runs after that. */ private run; private record; }