Skip to content

test: consolidate workspace CLI invocation harnesses - #2312

Merged
codeforester merged 3 commits into
mainfrom
enhancement/2308-20260918-consolidate-duplicated-workspace-cli-test-invocation-harness
Sep 19, 2026
Merged

codeforester merged 3 commits into
mainfrom
enhancement/2308-20260918-consolidate-duplicated-workspace-cli-test-invocation-harness

Conversation

@codeforester

@codeforester codeforester commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add one test-local workspace CLI invocation helper with explicit stream and environment overrides.
  • Migrate clone, configure, pull, and onboarding tests while preserving onboarding TTY simulation.
  • Cover environment and stream restoration on both success and exception paths.

Issue

Fixes #2308

Validation

  • Affected workspace modules: 44 passed, 2 subtests passed.
  • All base_projects tests: 389 passed, 64 subtests passed.
  • Pylint on touched tests/helper and git diff --check passed.

Demo Impact

None. No demo behavior changed.

Docs and AI Context

No .ai-context/ update is needed for this test-only refactor.

@codeforester
codeforester requested a review from a team as a code owner September 18, 2026 15:59
Comment thread cli/python/base_projects/tests/workspace_cli_helpers.py
@codeforester

Copy link
Copy Markdown
Collaborator Author

Addressed in commit 824efd7.

  • Migrated the remaining workspace CLI test invocation helpers to the shared helper, including setup, update, repository URL, status-manifest, agent-brief, and downstream imports.
  • Preserved terminal-output behavior in the shared helper and retained explicit environment overrides.
  • Focused validation: 172 tests passed, 40 subtests; Pylint and git diff --check pass.

@codeforester

Copy link
Copy Markdown
Collaborator Author

Follow-up on the previous review comment

The follow-up commit ("test: consolidate remaining workspace CLI helpers") addresses the main finding well - test_workspace_checks.py, test_workspace_repository_url.py, test_workspace_status_manifest.py, test_workspace_setup.py, test_workspace_update.py, test_manifest_input_errors.py, and a few others now correctly use the shared invoke_engine helper with no local duplicate harness code.

However, the original finding - the new file duplicating TerminalStringIO instead of hoisting it into workspace_cli_helpers.py - is only partially resolved. workspace_cli_helpers.py now does define the canonical TerminalStringIO class, which is great, but three files still define their own redundant local copy of the identical class instead of importing it, even though all three already import invoke_engine from that same module in the same import block:

  • cli/python/base_projects/tests/test_workspace_onboarding.py:72
  • cli/python/base_projects/tests/test_workspace_agent_brief.py:97
  • cli/python/base_projects/tests/test_workspace_cli_helpers.py:15

Simple fix: drop the local class TerminalStringIO(io.StringIO): ... in each of these three files and add TerminalStringIO to the existing from base_projects.tests.workspace_cli_helpers import invoke_engine line.

(test_engine.py also defines its own copy, but that one doesn't use invoke_engine at all, so it's out of scope for this consolidation.)

Posted via Claude Code

@codeforester

codeforester commented Sep 19, 2026

Copy link
Copy Markdown
Collaborator Author

Addressed the follow-up review comment and resolved the merge conflict in commit b1247f5.

  • Merged current origin/main (5f43fbb) into the PR branch; the only conflict was in test_workspace_setup.py, and both sides' behavior is preserved.
  • Removed duplicate TerminalStringIO definitions from test_workspace_onboarding.py, test_workspace_agent_brief.py, and test_workspace_cli_helpers.py.
  • Imported the canonical TerminalStringIO where it is still used; the agent-brief test had no remaining call sites.

Validation:

  • Full Python suite: 1,659 passed.
  • Pylint passed for the affected workspace test modules.
  • Focused workspace tests: 91 passed, 38 subtests.
  • The previously environment-sensitive gh branch stale Bats test passes with /usr/local/bin/git ahead of the macOS Xcode git shim.
  • git diff --check passed.

The PR remains open and unmerged.

@codeforester
codeforester merged commit 4614cc4 into main Sep 19, 2026
22 checks passed
@codeforester
codeforester deleted the enhancement/2308-20260918-consolidate-duplicated-workspace-cli-test-invocation-harness branch September 19, 2026 17:53
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.

Consolidate duplicated workspace CLI test invocation harnesses

1 participant