MCPcopy Create free account
hub / github.com/Noumena-Network/code / createFixture

Function createFixture

src/testing/wrapperPtyHarness.ts:149–188  ·  view source on GitHub ↗
(
  commandArgs: readonly string[],
  expectedRows: readonly string[],
  options?: {
    readonly tmpDir?: string
    readonly configDir?: string
    readonly cwd?: string
    readonly env?: NodeJS.ProcessEnv
    readonly startupTimeoutMs?: number
    readonly startupBudgetMs?: number
  },
)

Source from the content-addressed store, hash-verified

147}
148
149function createFixture(
150 commandArgs: readonly string[],
151 expectedRows: readonly string[],
152 options?: {
153 readonly tmpDir?: string
154 readonly configDir?: string
155 readonly cwd?: string
156 readonly env?: NodeJS.ProcessEnv
157 readonly startupTimeoutMs?: number
158 readonly startupBudgetMs?: number
159 },
160): WrapperPtyFixture {
161 const tmpDir = options?.tmpDir ?? mkdtempSync(join(tmpdir(), 'code-wrapper-pty-'))
162 const configDir = options?.configDir ?? join(tmpDir, 'config')
163 mkdirSync(configDir, { recursive: true })
164 const startedAt = Date.now()
165 const session = spawnPtyContractSession(commandArgs, {
166 cwd: options?.cwd ?? WRAPPER_HARNESS_REPO_ROOT,
167 env: options?.env,
168 columns: 120,
169 lines: 40,
170 })
171
172 return {
173 tmpDir,
174 configDir,
175 session,
176 cwd: options?.cwd ?? WRAPPER_HARNESS_REPO_ROOT,
177 startupTimeoutMs: options?.startupTimeoutMs ?? 25_000,
178 startupBudgetMs: options?.startupBudgetMs ?? 18_000,
179 expectedRows,
180 getElapsedMs() {
181 return Date.now() - startedAt
182 },
183 cleanup() {
184 session.terminate()
185 rmSync(tmpDir, { recursive: true, force: true })
186 },
187 }
188}
189
190export function buildSteadyStateWrapperExpectedRows(
191 cwd = WRAPPER_HARNESS_REPO_ROOT,

Calls 2

mkdirSyncFunction · 0.90
spawnPtyContractSessionFunction · 0.85

Tested by

no test coverage detected