Skip to content

fix(ci): the fail-to-pass replay clears the addopts #5599

Description

@dan-petty

Problem

The Fail-to-Pass Check replays the tests of a fix with pytest -o addopts= (src/devops_cli/ci/fail_to_pass.py:6). The option clears the addopts of the project configuration.

tests/commands/test_test_selection.py::test_the_full_gate_collects_every_test_module reads addopts. Under the replay it fails on every base, but in a normal run it passes on the same base. So each fix that changes tests/commands/test_test_selection.py gets one false "failed on base" line for this test.

Found while an agent fixed PR #5547 (#4472) on 2026-11-14: the replay listed this test as failed on base, and the cause was the replay option, not the base.

Expected behavior

A test that passes on the base in a normal run also passes on the base in the replay. The replay does not report a failure that its own options cause.

Fix options (the plan decides)

  • Keep the addopts that a test reads, and clear only the options that change the replay result (for example coverage or parallel workers).
  • Or make the test read the configuration that the run uses, and not the raw addopts value.

Test first: a replay of tests/commands/test_test_selection.py on an unchanged base reports 0 failed on base.

Related

Source: #5547

Proposed design

Problem statement

The fail-to-pass replay passes pytest -o addopts= and clears the project addopts. The test tests/commands/test_test_selection.py::test_the_full_gate_collects_every_test_module reads addopts, so it fails on every base and gives a false failed on base line. The replay must keep addopts and override only coverage and parallel workers.

Acceptance criteria

Requirement: Replay keeps addopts

The fail-to-pass replay SHALL keep the project addopts value that a test reads.

Scenario: A test reads addopts under replay

  • WHEN The replay runs tests/commands/test_test_selection.py::test_the_full_gate_collects_every_test_module on an unchanged base.
  • THEN The replay reports 0 failed on base and adds no failed on base line for that test.

Requirement: Replay overrides coverage and workers

The fail-to-pass replay SHALL disable coverage and parallel workers with explicit pytest options and SHALL NOT clear addopts with -o addopts=.

Scenario: Replay command line

  • WHEN A fix changes a source file and the replay starts its pytest run.
  • THEN A unit test in tests/ci/test_fail_to_pass.py asserts that the command line contains --no-cov and -n 0, and does not contain -o addopts=.

Requirement: No false base failure from replay options

The replay SHALL report a base failure only when the test fails without the replay options.

Scenario: A test passes in a normal base run

  • WHEN A test passes on the base commit in a normal run and reads the project addopts.
  • THEN The replay reports 0 failed on base for that test.

Existing Tool Considered

No alternatives check has run. pytest, with pytest-cov and pytest-xdist, is already in use. It covers the need: --no-cov turns off coverage, and -n 0 turns off parallel workers. The project addopts stays in place. These tools lack a replay mode that keeps addopts, so the proposal adds the two flags to the replay command line. Cost: one command-line edit and one regression test, about 2k tokens and 30 minutes to build, keep and fix.

Key questions

  • Should the replay keep the project addopts and override only coverage and workers, or clear addopts?: Keep the project addopts. Add --no-cov and -n 0 to the replay command line, and remove -o addopts=. This keeps the value that a test reads and stops coverage and parallel workers from changing the replay. (best practice) [sources: src/devops_cli/ci/fail_to_pass.py:6, tests/commands/test_test_selection.py]
    • Chosen: Keep addopts and override coverage and workers. It preserves the configuration that a test reads, and explicit flags stop coverage and parallel workers from changing the replay.
    • Rejected: Clear addopts with -o addopts=. It causes the false base failure in fix(ci): the fail-to-pass replay clears the addopts #5599 because tests see an empty addopts.
    • Rejected: Change the affected test to read the effective run configuration. It treats the symptom, and the replay still clears configuration that any test may read.
  • Which pytest options disable coverage and parallel workers without clearing addopts?: --no-cov turns off coverage from pytest-cov, and -n 0 turns off workers from pytest-xdist. The rest of addopts stays in place, including -n logical as the value that a test reads. (best practice) [sources: tests/commands/test_test_selection.py]
    • Chosen: Use --no-cov and -n 0. They override the two replay-changing options and leave addopts in place.
    • Rejected: Filter the addopts string from pyproject.toml. It duplicates pytest parsing and can remove options that a test reads.
    • Rejected: Clear addopts. It causes the false base failure.
  • Does -o addopts= empty the project addopts for the replay?: Yes. Pytest -o overrides an ini value, and addopts= sets the value to an empty string. [sources: src/devops_cli/ci/fail_to_pass.py:6]
  • Which test reads addopts and gives the false base failure?: tests/commands/test_test_selection.py::test_the_full_gate_collects_every_test_module reads addopts. It passes on the base in a normal run and fails under the replay. [sources: tests/commands/test_test_selection.py, src/devops_cli/ci/fail_to_pass.py:6]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-20: none.
Tool: none found.
Reason: Searches found only pytest and its coverage and worker plugins, which the project already uses; none provides a replay that keeps addopts, so the fix stays a two-flag edit in the project's own replay command line.

Lacks:

  • No replay harness that runs a test set on a base commit
  • No check that flags failures caused by the replay options
  • No single option that keeps addopts and drops coverage and workers

Activity

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

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

    @devops-cli-service
    Contributor

    Waiting for the alternatives check to run. The next refine round looks at the item again after the check records a verdict.

  5. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (10)

    Tools considered:

    Searches run:

    • pytest --no-cov disable coverage option addopts, results: 5
    • pytest-xdist -n 0 disable parallel workers command line, results: 5
    • pytest-cov documentation --no-cov option, results: 5
    • pytest-xdist numprocesses zero -n0 run tests in main process, results: 5
    • pytest -o addopts override ini option command line, results: 5
    • pytest documentation addopts ini option, results: 5
    • pytest-xdist github repository, results: 5
    • pytest, results: 5
    • pytest-cov "no-cov", results: 5
    • replay failed tests on base commit pytest tool, results: 5

    Sources:

  6. dan-petty commented on Nov 21, 2026

    @dan-petty
    OwnerAuthor

    This defect now stops the Fail-to-Pass Check of a fix, and it does not only add a false line.

    Issue #6564 (P0, pull request #6568) changes tests/commands/test_test_selection.py. uv run devops ci fail-to-pass --base origin/main on that branch reports test_the_full_gate_collects_every_test_module as failed on the base, and then exits 1 with: "A test that the fix does not change does not pass on the head". The cause is the same: the replay gives -o addopts=, and the test reads addopts.

    In a normal run on the same head, the test passes (uv run pytest -n 0 tests/commands/test_test_selection.py::test_the_full_gate_collects_every_test_module: 1 passed).

    So each fix that changes tests/commands/test_test_selection.py gets a red Fail-to-Pass Check until this item is fixed. This item blocks #6564.

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

    @devops-cli-service
    Contributor
  10. devops-cli-service commented on Nov 21, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-21 06:24 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