Skip to content

fix(ci): a fail-to-pass test reads a head run as a base run #5361

Closed

Description

@dan-petty

Problem Description

In tests/ci/test_fail_to_pass.py, the helper _ran_on_base reads a gate row call as a base run when the name of its working folder is tree. The test test_the_command_exits_0_for_a_gate_check_that_proves_the_fix runs devops ci fail-to-pass with no root, so the command takes the worktree of the current folder as the root (find_worktree_root), and the head run of the gate row runs in that root.

The replay of devops ci fail-to-pass runs the changed test files in a base tree at <temp-dir>/tree. There, the root of the test is that folder, so the fake answers the head run with the base output. The case then fails on head too, the replay proves nothing, and the test fails on base with assert (1, True, False) == (0, True, False). A checkout whose folder has the name tree gets the same failure.

Reproduction Steps

  1. Change only the body of one test function of tests/ci/test_fail_to_pass.py on a fix branch.
  2. Run uv run devops ci fail-to-pass --base origin/main.
  3. The replay shows failed on base: tests.ci.test_fail_to_pass::test_the_command_exits_0_for_a_gate_check_that_proves_the_fix (assert (1, True, False) == (0, True, False)). The fix does not change that test, so the replay refuses the fix.

Expected vs Actual Behavior

Expected: the test passes on the base tree of a replay, and in a checkout of any folder name.

Actual: the test fails when the root of the command has the folder name tree.

Environment Diagnostics

  • DevOps CLI Version: 0.126.0
  • Execution Environment: devcontainer, a worktree of devops-cli at a fix branch

Logs, Traces, or Terminal Output

failed on base: tests.ci.test_fail_to_pass::test_the_command_exits_0_for_a_gate_check_that_proves_the_fix (assert (1, True, False) == (0, True, False))

Proposed Fix

Make the fake know the base tree from the git worktree add call that it answers, not from the folder name, or run the command of the test in a root under tmp_path.

The replay of the fix of #5353 showed this failure.

Alternatives check of 2026-11-17: none.
Tool: none found.

Proposed design

Problem statement

Fix the gate-row fake to use the worktree path recorded by git worktree add, not the folder name tree. The helper _ran_on_base in tests/ci/test_fail_to_pass.py treats any working folder named tree as the base replay tree. A head gate run whose checkout root is named tree then gets the base answer, so the replay proves nothing and test_the_command_exits_0_for_a_gate_check_that_proves_the_fix fails on base.

Acceptance criteria

Requirement: Recorded base worktree

The gate-row fake SHALL identify a base run by the worktree path that git worktree add recorded, not by the working folder name.

Scenario: Recorded base worktree

  • WHEN A gate row runs in the worktree that _handle_worktree_add recorded.
  • THEN The unit test asserts that _gate_row_answer returns gate_base.

Requirement: Unrecorded folder named tree

The gate-row fake MUST NOT treat a working folder named tree as a base worktree when no git worktree add recorded that path.

Scenario: Unrecorded folder named tree

  • WHEN A gate row runs in a folder whose last path component is tree, and _handle_worktree_add recorded no such path.
  • THEN The unit test asserts that _gate_row_answer returns gate_head.

Requirement: Gate check test in tree checkout

The test test_the_command_exits_0_for_a_gate_check_that_proves_the_fix SHALL pass when the checkout root folder is named tree.

Scenario: Checkout root named tree

  • WHEN The regression test sets the command root to a folder named tree that is not a recorded base worktree.
  • THEN The test asserts that the command exits 0 and gate_head is the answer for the gate row.

Existing Tool Considered

The alternatives check of 2026-11-17 records verdict none and no tool (see the alternatives block in the issue body). No open maintained tool or library covers the need. The change edits the existing test helper _ran_on_base and adds no library. The change builds no new tool; it edits existing test code.

Key questions

  • How does the command choose its root when the test passes no root?: It uses find_worktree_root on the current folder. [sources: src/devops_cli/core/repo.py:256, tests/ci/test_fail_to_pass.py:1369]
  • How should _ran_on_base tell a base gate run from a head gate run?: Use the worktree paths recorded by _handle_worktree_add in replay_state.active_worktrees. Test whether the call's working folder is that path or inside it. (best practice) [sources: tests/ci/test_fail_to_pass.py:268, tests/ci/test_fail_to_pass.py:1369]
    • Chosen: Recorded worktree path. The fake already records each git worktree add destination in active_worktrees and removes it on git worktree remove; this uses the actual add call.
    • Rejected: Folder name tree. This is the defect: a checkout root named tree gets the base answer for a head run.
    • Rejected: Run the test in a root under tmp_path. This hides the defect in one test and leaves the folder-name assumption for other callers.
  • Should a folder inside the recorded base worktree count as a base run?: Yes. Use Path(call.cwd).resolve().is_relative_to(worktree) for each recorded worktree, so a gate row in a subfolder of the base tree gets gate_base. (best practice) [sources: tests/ci/test_fail_to_pass.py:268]
    • Chosen: Path or descendant of recorded worktree. The helper documents the replay tree, and a subfolder is still inside that tree.
    • Rejected: Exact path equality only. It fails if the gate row runs from a subfolder of the recorded base tree.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

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

    @dan-petty
    OwnerAuthor
  3. added
    priority/p2-medium
    on Nov 13, 2026
  4. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: Searches for a pytest fixture or library that fakes a git worktree add call, keys a fake subprocess answer by command rather than by path, or locates a worktree root returned only unrelated general pages, not a maintained tool that covers the need. The defect is in the repository's own test helper _ran_on_base, which infers the base tree from the folder name tree; only a change to that helper (reading the base tree from the git worktree add call it answers, or running the command in a root under tmp_path) fixes it, so no open tool or library covers the need.

    Tool: none found

    Lacks:

    • A fake that learns the base tree from the git worktree add call it answers instead of from the folder name tree
    • Running the gate-check command in a root under tmp_path so the head run cannot land in the base tree
    • The fix must live in the project's own helper _ran_on_base / test setup, not in a third-party package

    Searches run:

    • pytest fixture tmp_path git worktree add fake subprocess test, results: 5
    • python library detect git worktree root path instead of folder name, results: 5
    • pytest fake subprocess record calls keyed by command arguments instead of path, results: 5
    • python library parse "git worktree list --porcelain" worktree path, results: 5
    • git rev-parse --show-toplevel python find repository root, results: 5
    • pytest-subprocess fake process fixture, results: 5
    • pytest plugin temporary git repository fixture create worktree, results: 5

    Checked on 2026-11-17. A person decides what this means for the item. The check changes no label and closes no issue.

  5. added
    status/ready
    and removed
    status/new
    on Nov 17, 2026
  6. devops-cli-service commented on Nov 17, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 666a03f (see proposed design in issue body).

  7. added
    status/in-review
    and removed
    status/ready
    on Nov 18, 2026
  8. removed
    status/in-review
    on Nov 18, 2026
  9. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-18 17:16 UTC

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/lowpriority/p2-mediumscope/cisource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions