Stub rubocop subprocess in autocorrect-prepass tests #487

Closed
opened 2026-08-23 13:48:34 +00:00 by jared · 3 comments
Owner

Context

13 tests (AutocorrectPrepassTest, CliAutocorrectPrepassTest) invoke the real rubocop binary via Open3.capture3 (lib/os_sdlc/autocorrect_prepass.rb:45) at ~1.3s each, ~17s of suite time, dominated by rubocop cold start.

Tasks

  • Stub the rubocop invocation for tests exercising config-resolution/reporting logic, reusing the in-process RuboCop::Cop::Team approach from CopTestHelper where practical.
  • Keep 1-2 true end-to-end tests running the real binary.

Acceptance criteria

~12-15s suite-time saving; end-to-end coverage of the real subprocess path retained.

Origin

  • Trigger: manual full-suite run of plugins/os-sdlc tests on 2026-08-23 (77.9s, 1 failure) prompting a root-cause probe session
  • Improvised: none
  • Chain: slow autocorrect tests ← real rubocop subprocess per test ← AutocorrectPrepass shelling out by design — DESIGN (lib/os_sdlc/autocorrect_prepass.rb:45)
  • Root candidate: this ticket
## Context 13 tests (AutocorrectPrepassTest, CliAutocorrectPrepassTest) invoke the real rubocop binary via Open3.capture3 (lib/os_sdlc/autocorrect_prepass.rb:45) at ~1.3s each, ~17s of suite time, dominated by rubocop cold start. ## Tasks - [ ] Stub the rubocop invocation for tests exercising config-resolution/reporting logic, reusing the in-process RuboCop::Cop::Team approach from CopTestHelper where practical. - [ ] Keep 1-2 true end-to-end tests running the real binary. ## Acceptance criteria ~12-15s suite-time saving; end-to-end coverage of the real subprocess path retained. ## Origin - Trigger: manual full-suite run of plugins/os-sdlc tests on 2026-08-23 (77.9s, 1 failure) prompting a root-cause probe session - Improvised: none - Chain: slow autocorrect tests ← real rubocop subprocess per test ← AutocorrectPrepass shelling out by design — DESIGN (lib/os_sdlc/autocorrect_prepass.rb:45) - Root candidate: this ticket
Author
Owner

Work started: stubbing rubocop subprocess in autocorrect-prepass tests (batch session 2026-08-23).

Work started: stubbing rubocop subprocess in autocorrect-prepass tests (batch session 2026-08-23).
Author
Owner

Resolution

Done: Stubbed rubocop for the config-resolution/reporting tests via new FakeRubocopRunner (RuboCop::Cop::Team in-process, CopTestHelper pattern) injected through the existing AutocorrectPrepass runner: seam; kept the end-to-end test on the real binary. The 5 CliAutocorrectPrepassTest subprocess tests were deliberately left on the real binary: they pin the process boundary by documented design (tests/autocorrect_prepass_test.rb:8-12) and stubbing across it would need a speculative env-var seam.

Evidence: Commit 7ef230e: 2 test files, 77 insertions. Targeted run 15 runs, 55 assertions, 0 failures. Full suite 1035 runs, 0 failures, 49.1s (vs 51.9s post-#486). Saving 2.8s, short of the ticket's 12-15s estimate; the estimate assumed all 13 tests could be stubbed, but 5 pin the subprocess boundary intentionally. Residual wait is subprocess I/O, absorbed by parallelization ticket #488.

Follow-ups: Dropped: env-var runner seam for the CLI subcommand tests — speculative cross-process seam; #488 parallelization absorbs the residual time. Dropped: FakeRubocopRunner COPS-list future-proofing — speculative; the fixture's cop list is stable and a mismatch fails loudly.

## Resolution **Done:** Stubbed rubocop for the config-resolution/reporting tests via new FakeRubocopRunner (RuboCop::Cop::Team in-process, CopTestHelper pattern) injected through the existing AutocorrectPrepass runner: seam; kept the end-to-end test on the real binary. The 5 CliAutocorrectPrepassTest subprocess tests were deliberately left on the real binary: they pin the process boundary by documented design (tests/autocorrect_prepass_test.rb:8-12) and stubbing across it would need a speculative env-var seam. **Evidence:** Commit 7ef230e: 2 test files, 77 insertions. Targeted run 15 runs, 55 assertions, 0 failures. Full suite 1035 runs, 0 failures, 49.1s (vs 51.9s post-#486). Saving 2.8s, short of the ticket's 12-15s estimate; the estimate assumed all 13 tests could be stubbed, but 5 pin the subprocess boundary intentionally. Residual wait is subprocess I/O, absorbed by parallelization ticket #488. **Follow-ups:** Dropped: env-var runner seam for the CLI subcommand tests — speculative cross-process seam; #488 parallelization absorbs the residual time. Dropped: FakeRubocopRunner COPS-list future-proofing — speculative; the fixture's cop list is stable and a mismatch fails loudly.
jared closed this issue 2026-08-23 14:48:47 +00:00
Author
Owner

Follow-up (user-decided): deleted the 5 CliAutocorrectPrepassTest subprocess tests; in-process unit and runner-contract tests retained. Commit f4e386c.

Follow-up (user-decided): deleted the 5 CliAutocorrectPrepassTest subprocess tests; in-process unit and runner-contract tests retained. Commit f4e386c.
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#487
No description provided.