Skip to content

test(cli-e2e): use shared runCli helper from @inquirerer/test#33

Merged
pyramation merged 2 commits intomainfrom
feat/cli-e2e-shared-runner
Apr 26, 2026
Merged

test(cli-e2e): use shared runCli helper from @inquirerer/test#33
pyramation merged 2 commits intomainfrom
feat/cli-e2e-shared-runner

Conversation

@pyramation
Copy link
Copy Markdown
Contributor

Summary

Replaces the hand-rolled runCli + parseArgs in cli-e2e.test.ts (~75 lines of child_process.spawn plumbing, timeout handling, and quote-aware arg parsing) with a thin wrapper around runCli + parseArgString from @inquirerer/test. The upstream helper provides identical semantics:

  • spawn with piped stdio
  • capture stdout/stderr as strings
  • enforce a per-call timeout (with SIGKILL)
  • reject on non-zero exit code, with the captured streams attached to the error
  • shell-string arg parsing that respects single/double quotes

The local runCli(args, options) keeps its existing Promise<string> signature so all 14 call sites in this file are unchanged — it just delegates the subprocess management to the upstream helper.

- import { spawn } from 'child_process';
+ import { runCli as runCliSubprocess, parseArgString } from '@inquirerer/test';

- function parseArgs(args: string): string[] { /* 20 lines */ }
- function runCli(args: string, opts): Promise<string> { /* 50 lines */ }
+ function runCli(args: string, options: { timeout?: number } = {}): Promise<string> {
+   return runCliSubprocess(TSX_BIN, [CLI_ENTRY, ...parseArgString(args)], {
+     cwd: REPO_ROOT,
+     env: { ...process.env, HOME: testHome, /* ... */ },
+     timeout: options.timeout || CLI_TIMEOUT,
+   }).then((result) => result.stdout);
+ }

Net diff: +25 / −75.

Review & Testing Checklist for Human

  • Blocked on dev-utils#79 + npm publish. The runCli and parseArgString exports first appear in @inquirerer/test@1.4.x; current latest on npm is 1.3.5. This PR is filed as draft so it can be reviewed alongside constructive-io/dev-utils#79; promote out of draft once @inquirerer/test@1.4.0 (or whatever Lerna picks) is on npm and pnpm install resolves the new version.
  • After the publish lands, run pnpm --filter @agentic-db/cli-e2e-tests test end-to-end against a Docker constructiveio/postgres-plus:18 + Ollama (with nomic-embed-text pulled). All 18 tests should still pass — the harness change is non-behavioral but the subprocess surface is the kind of thing that benefits from a real run.
  • Confirm error formatting still looks reasonable when a CLI command fails (the upstream helper's RunCliError attaches .stdout, .stderr, .exitCode, etc. but stringifies similarly to the previous hand-rolled Error).

Notes

Companion PRs:

  • constructive-io/dev-utils#79 — adds runCli + parseArgString to @inquirerer/test, plus a Testing section in inquirerer's main README pointing at the package. Must merge + publish first.
  • constructive-io/constructive#1027 — drops the local re-export indirection in packages/cli/test-utils and imports directly from @inquirerer/test. Independent of this PR.

The intent across all three is to make @inquirerer/test the canonical place for both in-process Inquirerer testing (createTestEnvironment, setupTests, KEY_SEQUENCES) and out-of-process CLI E2E testing (runCli, parseArgString), so future tests don't have to re-roll the same harness patterns.

Link to Devin session: https://app.devin.ai/sessions/81001448b7c54b8099437f706d44a30d
Requested by: @pyramation

Replaces the hand-rolled runCli + parseArgs (~75 lines) with a thin
wrapper around runCli + parseArgString from @inquirerer/test. The shared
helper provides identical semantics: spawn, capture stdout/stderr,
enforce a timeout, reject on non-zero exit code with stdout/stderr
attached to the error.

The local function keeps its (args: string, options) signature and
returns Promise<string> so all 14 call sites are unchanged — it just
delegates to the upstream helper for the actual subprocess management.

NOTE: Blocked on constructive-io/dev-utils#79 + a publish of
@inquirerer/test (the runCli/parseArgString exports first appear in
1.4.0). This PR is filed as a draft so it can be reviewed in advance.
@devin-ai-integration
Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@devin-ai-integration devin-ai-integration Bot marked this pull request as ready for review April 26, 2026 22:46
@pyramation pyramation merged commit af43a4f into main Apr 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant