Skip to content

fix(ci): Fix mutants tree tests reading Git tracking or src #6474

Done

Description

@devops-cli-service

Split from #6448.

Problem: A prepared mutants tree with its own .git still has 57 failing tests. Most of them read the Git tracking of the checkout, and the new repository has no commit. The others read src as data, which is the generated code of mutmut. Why deferred: The repository-metadata change in #6448 fixes the guard stop and the missing .git. It does not change the tests that read checkout state or generated source. Those tests need their own fixes or a documented exclusion. Acceptance criteria: A run of the mutation selection in a prepared mutants tree reports no failure from the 57 tests named in #6448. Each test that needs checkout tracking gets a fixture or an exclusion with a reason. Each test that reads src as data gets a stable source path or an exclusion with a reason. The stats run of devops ci mutate reports no failure from these tests.

Proposed design

Problem statement

The prepared mutants tree has its own .git but no commit. Tests that read the checkout's Git tracking fail. Other tests read src as data and see mutmut's generated code. This issue makes the Git-tracking tests use the git_fake seam and a repository fixture with a recorded commit. It excludes the tests that need the checkout's full history or read src as data from the mutation selection with a reason. It proves the selection with a run of devops ci mutate in the prepared tree.

Acceptance criteria

Requirement: Git-tracking fixture

A test that reads Git tracking SHALL install the git_fake fixture and a repository fixture that answers git rev-parse HEAD with a recorded commit, and it MUST start no real git.

Scenario: Test that reads HEAD

  • WHEN a test installs git_fake and the repository fixture and calls the product's git rev-parse HEAD
  • THEN the product returns the fixture's commit and GitFake records no real git start.

Requirement: Full-history exclusion

A test that needs the checkout's full Git history MUST be excluded from the mutation selection with a comment that names the reason.

Scenario: One-commit prepared tree

  • WHEN uv run devops ci mutate src/devops_cli/ci/mutate.py runs on a prepared mutants tree whose .git holds one commit
  • THEN the run reports no failure from tests/invariants/test_source_tree.py::test_a_moved_roadmap_module_keeps_its_history and lists the killed, survived, timeout and no-tests counts.

Requirement: Source-data exclusion

A test that reads src as data MUST be excluded from the mutation selection with a comment that names the reason, because the prepared tree holds only mutmut's generated code.

Scenario: Source-data test in the prepared tree

  • WHEN uv run devops ci mutate src/devops_cli/ci/mutate.py runs on a prepared mutants tree
  • THEN the run reports no failure from a test that reads src as data and lists the killed, survived, timeout and no-tests counts.

Requirement: Prepared-tree stats run

A prepared mutants tree MUST report no failure from the 57 tests that #6448 names.

Scenario: Mutation selection stats run

  • WHEN uv run devops ci mutate src/devops_cli/ci/mutate.py runs on a prepared mutants tree
  • THEN the stats run reports zero failures and the counts of killed, survived, timeout and no-tests mutants.

Existing Tool Considered

No alternatives check has run. pytest is the open, maintained test framework that the repository already uses; it covers fixtures and test selection but has no Git repository fixture that starts no real git. The repository already owns the git_fake seam (tests/support/fakes/git.py:121) and a git_repo support fixture (tests/support/roadmap_refine.py:159). The change adds a shared repository fixture with one recorded commit, about 30 lines of test code, and no production code. Written cost: under 1k tokens and under 1 hour to build, keep and fix. The seam, fake and transcripts already exist.

Key questions

  • How should a test that reads Git tracking get a repository?: Install the git_fake fixture and a shared repository fixture that creates .git and answers git rev-parse HEAD from a recorded commit. The fixture starts no real git. A test that needs the checkout's full history is excluded from the mutation selection with a reason. (best practice) [sources: tests/support/fakes/git.py:121, tests/support/roadmap_refine.py:159, src/devops_cli/ci/mutate.py]
    • Chosen: Fake git seam with a recorded commit. It follows the existing git_fake seam and the git_repo support fixture, and the fixture and transcripts already exist.
    • Rejected: Real temporary git repository. A test of src starts no program, and the existing seam already gives the answers.
    • Rejected: Mock each git command. It couples tests to command strings and bypasses the one process seam.
    • Rejected: Exclude every Git-tracking test. It hides tests that the fake and one recorded commit can run.
  • How should a test that reads src as data resolve the source?: Exclude it from the mutation selection with a reason. The prepared tree's src is mutmut's generated code and holds no unmutated copy. A test that reads a non-Python file under src stays in, because mutmut copies that file unchanged. (best practice) [sources: src/devops_cli/ci/mutate.py, tests/support/paths.py:21]
    • Chosen: Exclusion with a reason in the mutation selection. The tree holds only generated source, and the selection is the mechanism the mutation run reads.
    • Rejected: Stable source-root fixture. REPO_ROOT is the prepared tree root and its src is generated; a parent checkout is not guaranteed.
    • Rejected: Hard-coded src path. It points at generated code.
    • Rejected: Keep every source-data test and make it pass. A test that asserts the source text cannot pass against mutated text.
  • Which exclusion mechanism should the mutants tree use?: The existing pytest_add_cli_args_test_selection list in pyproject.toml, with a comment on each entry that names the reason. Do not add a pytest marker or a second exclusion file: the mutation run passes no marker filter. (best practice) [sources: pyproject.toml:304, src/devops_cli/ci/mutate.py]
    • Chosen: Existing selection entries with a reason comment. It is the list mutmut reads, and the repository already documents each entry with a comment.
    • Rejected: Pytest marker with a reason. The mutation run applies no marker filter, so the marked test still runs.
    • Rejected: Custom exclusion file. It adds a second source of truth that drifts.
    • Rejected: CI-only ignore list. It hides the reason from the test and the reviewer.
  • Which test needs the checkout's full Git history?: tests/invariants/test_source_tree.py::test_a_moved_roadmap_module_keeps_its_history fails in a one-commit tree because its guard skips only when git rev-parse --is-shallow-repository fails, and a one-commit repository answers false; the following git log --follow then asserts more than one commit and fails. The test is excluded from the mutation selection with a reason. [sources: tests/invariants/test_source_tree.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#6448

Activity

  1. added
    type/bug
    scope/ci
    source/agent
    status/new
    effort/medium
    value/high
    on Nov 19, 2026
  2. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    ContributorAuthor
    • Priority: P0-Critical. The 57 failing tests cause the devops ci mutate stats run to report failures, which is a CI failure.
    • Related: fix(ci): the stats run fails in the mutants tree #6448, which asks for a different change. Both address devops ci mutate failures in the mutants tree; #6448 fixes the guard stop and missing .git, this item fixes 57 tests reading checkout state or src as data.
  3. added
    priority/p0-critical
    on Nov 19, 2026
  4. changed the title [-]fix(ci): make the mutants tree pass tests that read Git tracking or src as data[/-] [+]fix(ci): Fix mutants tree tests reading Git tracking or src[/+] on Nov 19, 2026
  5. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    ContributorAuthor

    The job shortened the title of this item. The summary had 70 characters, and the limit is 60. The type and the scope stay.

    • Before: fix(ci): make the mutants tree pass tests that read Git tracking or src as data
    • After: fix(ci): Fix mutants tree tests reading Git tracking or src
    • Source of the summary: the background model
  6. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    ContributorAuthor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  7. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 23, 2026
  8. removed
    status/in-review
    owner/agent
    on Nov 23, 2026
  9. devops-cli-service commented on Nov 23, 2026

    @devops-cli-service
    ContributorAuthor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

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/p0-criticalscope/cisource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions