Skip to content

test(ci): ci and test selection command tests patch no names #4087

Closed

Description

@dan-petty

Problem or Motivation

Parent #3769 asks that the command tests patch no name of devops_cli. Group 3 is the tests of devops ci: tests/commands/test_ci.py, test_ci_build_index.py, test_ci_dry_run.py, test_ci_shard.py, test_ci_repeat.py, test_ci_maintain.py, test_ci_gate_rows.py and test_test_selection.py.

Measured at origin/main 74ba76b (2026-11-07) with an AST count of the calls to monkeypatch.setattr, patch and patch.object in these files: 106 patches name a devops_cli module in a string (45 in test_ci.py, 11 in test_ci_build_index.py, 2 in test_ci_dry_run.py, 48 in test_test_selection.py), and 28 more patch an attribute of the imported ci module object (23 in test_ci.py, 5 in test_ci_shard.py). That is 134 patches of a devops_cli name in 5 of the 8 files.

Product code also holds two accommodations for these tests:

The change folder openspec/changes/1325-ci-commands-edge-fakes plans this work, but its parent #1325 is closed and the plan is stale.

Proposed Solution & Architectural Design

  • Replace each patch with the fake of the edge the command reaches: process_fake for programs, git_fake for git, a root of its own under tmp_path for the checked tree, the config fixture for settings, and the real cache functions of devops_cli.ci.cache for the cache.
  • Run each test that starts the gate in a root under tmp_path, so that the gate cleans only files of that root.
  • Remove the two PYTEST_CURRENT_TEST reads. Then the ceiling in tests/invariants/test_source_tree.py goes from 2 to 0 and becomes a ban.
  • Remove _current_run_subprocess and _ORIG_RUN_SUBPROCESS.
  • Where a test patched a private helper that holds logic, test the behavior through the command, or move the logic behind a public function of its domain package.
  • Keep every test of the group. The behavior each test checks does not change.
  • State the count of patches of the group before and after in the pull request.
  • Fix or archive the stale plan openspec/changes/1325-ci-commands-edge-fakes.

Target Subsystem

SDLC, Git & PR Governance.

Existing Tool Considered

No new tool is needed. process_fake, git_fake, the config fixture and pytest cover the need. The cost of the fakes is already paid by #1313 to #1325.

Acceptance criteria

  • git grep finds no string patch of a devops_cli name in the files of group 3.
  • The test identifiers of the group collected before and after match, and each passes.
  • A product mutation in the code that a migrated test covers makes that test fail.
  • PYTEST_CURRENT_TEST is read nowhere in src/, and tests/invariants/test_source_tree.py bans the read.

Related

Related: #3769

Activity

  1. added
    source/agent
    type/test
    scope/ci
    status/new
    value/medium
    effort/medium
    on Nov 7, 2026
  2. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/test. The test prefix of the title gives the type.
    • Scope: scope/ci. The (ci) scope of the title gives the scope.
    • Priority: P2-Medium. Removing test coupling and product-code accommodations improves maintainability but does not block a user-facing release.
    • Value: Medium. Removes 134 internal patches and two product-code accommodations, reducing test fragility and hidden coupling.
    • Effort: Medium. Replacing 134 patches across 8 files with edge fakes and removing two product-code accommodations is a focused but multi-file change.
    • Related: test(cli): command tests patch no devops_cli names #3769, which asks for a different change. Both remove string patches of devops_cli names from command tests, but the candidate covers only group 3 (8 CI/test-selection files) while #3769 covers all command test files.
  3. added
    priority/p2-medium
    on Nov 7, 2026
  4. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 8, 2026
  5. removed
    status/in-review
    on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/cisource/agenttype/testvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions