Run os-backlog CLI tests in-process #1333

Closed
opened 2026-10-25 19:48:32 +00:00 by jared · 2 comments
Owner

Problem

SubprocessCliRun starts the os-backlog bin as a subprocess. issue_create_ledger_origin_gate_cli_test uses it in 9 tests. About 4 s of the 15.4 s os-backlog suite goes to these spawns.

Approach

Replace SubprocessCliRun in the 9 tests with Backlog::CLI.start(ARGV, state_dir:, runner:) (cli.rb:7). Keep bin_missing_gems_guard_test as the smoke test: it proves the ADR-0123 missing-Thor exit.

Behavior is unchanged. The existing suite is the proof. Each bin or hook keeps exactly one smoke test, in a file named <bin>_bin_smoke_test.rb. The smoke test runs it as a subprocess to prove the plain-ruby boot and the shebang. Calls to external tools (git, rubocop) stay as subprocess calls.

Required work:

  1. Convert issue_create_ledger_origin_gate_cli_test to call Backlog::CLI.start with an injected state_dir and runner.
  2. Delete tests/support/subprocess_cli_run.rb when no test uses it.
  3. Rename bin_missing_gems_guard_test to os_backlog_bin_smoke_test.rb and keep its missing-Thor assertion.
  4. Remove the class — check: absent SubprocessCliRun in plugins/os-backlog/tests/**/*.rb

Acceptance criteria

  1. Given the converted tests, when the suite runs, then no test outside a *_bin_smoke_test.rb file starts a plugin bin/ or hooks/ script as a subprocess.
  2. Given each bin and hook, when its smoke test runs, then it boots with plain ruby and exits 0 on --help or on empty valid input.
  3. Given a missing Thor gem, when the smoke test runs the bin, then it exits as ADR-0123 requires.
  4. Given the converted tests, when they run, then they pass with the same assertions as before.

Owner sketch

Backlog::CLI.start(argv, state_dir:, runner:).

Origin

  • Trigger: ruby plugins/os-sdlc/tests/all.rb took 65.8 s against a 60 s budget. About 70% of summed test time is tests that start our own bin scripts with Open3.
  • Improvised this session: none
  • Chain: suite over budget ← tests start our own Ruby bin, hook, or CLI as a subprocess (Ruby boot cost per call) ← no rule says to call the in-process entry (Jared ruling, 2026-10-25; habit, no ADR)
  • Root candidate: none found; searched Open3, subprocess, in-process, bin_test, run_bin, Boot.run, ProcessIO
  • Where: plugins/os-backlog/tests/support/subprocess_cli_run.rb
  • Session: 01c29715-c945-43b4-86fc-6c5fc6c4dd3f
  • Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/01c29715-c945-43b4-86fc-6c5fc6c4dd3f.jsonl
## Problem `SubprocessCliRun` starts the os-backlog bin as a subprocess. `issue_create_ledger_origin_gate_cli_test` uses it in 9 tests. About 4 s of the 15.4 s os-backlog suite goes to these spawns. ## Approach Replace `SubprocessCliRun` in the 9 tests with `Backlog::CLI.start(ARGV, state_dir:, runner:)` (`cli.rb:7`). Keep `bin_missing_gems_guard_test` as the smoke test: it proves the ADR-0123 missing-Thor exit. Behavior is unchanged. The existing suite is the proof. Each bin or hook keeps exactly one smoke test, in a file named `<bin>_bin_smoke_test.rb`. The smoke test runs it as a subprocess to prove the plain-ruby boot and the shebang. Calls to external tools (git, rubocop) stay as subprocess calls. Required work: 1. Convert `issue_create_ledger_origin_gate_cli_test` to call `Backlog::CLI.start` with an injected `state_dir` and `runner`. 2. Delete `tests/support/subprocess_cli_run.rb` when no test uses it. 3. Rename `bin_missing_gems_guard_test` to `os_backlog_bin_smoke_test.rb` and keep its missing-Thor assertion. 4. Remove the class — check: absent `SubprocessCliRun` in `plugins/os-backlog/tests/**/*.rb` ## Acceptance criteria 1. Given the converted tests, when the suite runs, then no test outside a `*_bin_smoke_test.rb` file starts a plugin `bin/` or `hooks/` script as a subprocess. 2. Given each bin and hook, when its smoke test runs, then it boots with plain ruby and exits 0 on `--help` or on empty valid input. 3. Given a missing Thor gem, when the smoke test runs the bin, then it exits as ADR-0123 requires. 4. Given the converted tests, when they run, then they pass with the same assertions as before. ## Owner sketch `Backlog::CLI.start(argv, state_dir:, runner:)`. ## Origin - Trigger: `ruby plugins/os-sdlc/tests/all.rb` took 65.8 s against a 60 s budget. About 70% of summed test time is tests that start our own bin scripts with Open3. - Improvised this session: none - Chain: suite over budget ← tests start our own Ruby bin, hook, or CLI as a subprocess (Ruby boot cost per call) ← no rule says to call the in-process entry (Jared ruling, 2026-10-25; habit, no ADR) - Root candidate: none found; searched Open3, subprocess, in-process, bin_test, run_bin, Boot.run, ProcessIO - Where: plugins/os-backlog/tests/support/subprocess_cli_run.rb - Session: 01c29715-c945-43b4-86fc-6c5fc6c4dd3f - Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/01c29715-c945-43b4-86fc-6c5fc6c4dd3f.jsonl
Author
Owner

Work started in /os-sdlc:fast-batch fast-batch-15, branch fast-batch-15.

Work started in /os-sdlc:fast-batch fast-batch-15, branch fast-batch-15.
Author
Owner

Resolution

Done: os-backlog tests call Backlog::CLI.start in-process through InProcessCliRun; SubprocessCliRun deleted; os_backlog_bin_smoke_test.rb.

Evidence: Finding E 4b6d0a63, 115e3711; fix R17 1ae9c537. os-backlog suite 21.1 s to 0.96 s. Suites at c9f5db8f: os-sdlc 2701 runs 0 failures (53.1 s, budget 60 s), os 47, os-backlog 327, os-aidd-lint 491, os-adr 111, os-me 399, cc-architect plugin_config 106, all green. Merged to main c9f5db8f, pushed be5d2c5d. Batch state and rulings: docs/crc/os-sdlc/fast-batch-15/.

Follow-ups: #1407 (Checkout reads ENV USER; one test stays a subprocess until then), #1408 (NewOffenseCheck false red), #1337 (cop).

## Resolution **Done:** os-backlog tests call Backlog::CLI.start in-process through InProcessCliRun; SubprocessCliRun deleted; os_backlog_bin_smoke_test.rb. **Evidence:** Finding E 4b6d0a63, 115e3711; fix R17 1ae9c537. os-backlog suite 21.1 s to 0.96 s. Suites at c9f5db8f: os-sdlc 2701 runs 0 failures (53.1 s, budget 60 s), os 47, os-backlog 327, os-aidd-lint 491, os-adr 111, os-me 399, cc-architect plugin_config 106, all green. Merged to main c9f5db8f, pushed be5d2c5d. Batch state and rulings: docs/crc/os-sdlc/fast-batch-15/. **Follow-ups:** #1407 (Checkout reads ENV USER; one test stays a subprocess until then), #1408 (NewOffenseCheck false red), #1337 (cop).
jared closed this issue 2026-10-26 21:21:27 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jared/cc-os#1333
No description provided.