Skip to content

fix(ci): a gate module with no case passes #7315

Done

Description

@dan-petty

Problem

tests/gate/runner.main returns 0 when a gate module gives no case. A row whose checks are gone, or are not collected, passes.

Done when

  • The runner exits non-zero when it collects no case, and names the module. A test fails on the base.

Alternatives check of 2026-11-26: none.
Tool: none found.
Reason: Searches returned no tool that covers this: the gate runner is the project's own harness, and a framework's empty-suite exit code (pytest's 5) applies only to its own collected tests, so the guard is a local code change.

Lacks:

  • Non-zero exit when a module collects no case
  • The module named in the failure output
  • A test that fails on the base

Proposed design

Problem statement

The gate runner tests/gate/runner.main returns 0 when a gate module supplies no case. A gate row whose checks are gone, or are not collected, then passes. The change makes the runner exit non-zero, name the empty module, and pass the Fail-to-Pass Check.

Acceptance criteria

Requirement: Empty module helper

The new empty_gate_modules function SHALL return the name of each gate module that supplies no case.

Scenario: One empty module and one non-empty module

  • WHEN A test calls empty_gate_modules with a mapping that holds one empty case list and one non-empty case list.
  • THEN The call returns only the name of the empty module.

Requirement: Non-zero exit for an empty gate module

The gate runner SHALL exit with a non-zero status when a gate module supplies no case.

Scenario: A gate module supplies no case

  • WHEN A test calls the gate runner main function with a gate module that supplies no case.
  • THEN The call returns a non-zero exit status.

Requirement: The failure names the empty gate module

The gate runner MUST write the name of each gate module that supplies no case to standard error.

Scenario: The empty module name in standard error

  • WHEN A test calls the gate runner main function with a gate module that supplies no case and captures standard error.
  • THEN The captured standard error contains the name of that gate module.

Requirement: A non-empty gate module keeps the exit status zero

The gate runner SHALL return exit status zero when each gate module supplies at least one case.

Scenario: A gate module with one case

  • WHEN A test calls the gate runner main function with a gate module that supplies one passing case.
  • THEN The exit status is zero and standard error names no empty gate module.

Requirement: The Fail-to-Pass Check treats the runner as shared harness

The Fail-to-Pass Check SHALL treat a change to tests/gate/runner.py as a change to shared harness and SHALL NOT refuse it as an unowned gate module.

Scenario: A change to the shared runner

  • WHEN A test builds the Fail-to-Pass report with tests/gate/runner.py as the only changed gate path.
  • THEN The report is satisfied and no gate module replay is refused.

Requirement: The new test fails on the base

The change MUST add a test that fails against the base commit because the new devops_cli.ci.gate_runner module is absent.

Scenario: The new test at the base commit

  • WHEN uv run devops ci fail-to-pass --base <ref> replays the new test tests/ci/test_gate_runner.py against the base source.
  • THEN The replay shows the new test fails at collection with ModuleNotFoundError that names devops_cli.ci.gate_runner.

Existing Tool Considered

The alternatives check of 2026-11-26 in the issue body records the verdict none with no tool. The block gives the reason and the lacks list. The proposal covers the need with a new pure helper in src/devops_cli/ci/gate_runner.py and a shared-harness classification in src/devops_cli/ci/fail_to_pass.py. The local code costs about 20k tokens to write, keep and fix, and about 1 hour of elapsed time.

Key questions

  • Where does the gate runner detect a gate module that supplies no case?: A new pure helper empty_gate_modules in src/devops_cli/ci/gate_runner.py takes the collected cases by module. It returns the names with no case. The runner calls it after collection. It writes each name to standard error and returns 1. (best practice) [sources: tests/gate/runner.py, docs/TESTING.md, src/devops_cli/ci/fail_to_pass.py:476]
    • Chosen: Per-module helper in src/devops_cli/ci/gate_runner.py. It fails the exact row that lost its checks and names that module. It lives in src/, so a test fails on the base when the module is absent.
    • Rejected: One total count at the end. One empty module among full modules keeps the total above zero. The empty row still passes.
    • Rejected: The empty-collection exit code of pytest. The gate runner is the project's own harness. Code 5 of pytest covers only the tests that pytest collects.
  • How does the change pass the Fail-to-Pass Check for tests/gate/runner.py?: The change adds tests/gate/runner.py to the shared-harness paths in src/devops_cli/ci/fail_to_pass.py. The report then does not refuse the runner as an unowned gate module. The test at tests/ci/test_fail_to_pass.py:2525 uses another unowned module for the refused case. (best practice) [sources: src/devops_cli/ci/fail_to_pass.py:476, src/devops_cli/ci/fail_to_pass.py:703, tests/ci/test_fail_to_pass.py:2525]
    • Chosen: Shared-harness allowlist. runner.py is the shared harness of every gate row. It owns no single row, so the check must not refuse it.
    • Rejected: Add runner to CONST_GATE_MODULE_ROWS. The runner serves every row. A mapping to one row would misstate ownership.
    • Rejected: Move the runner to src/. The gate harness is test infrastructure. Product code holds nothing for tests.
  • How does the new test fail on the base when the Fail-to-Pass Check overlays tests/?: The new test imports devops_cli.ci.gate_runner, which is in src/. The base commit has no such module. The overlay replaces only tests/. The test then fails at collection with ModuleNotFoundError on the base. (best practice) [sources: src/devops_cli/ci/fail_to_pass.py:630, docs/TESTING.md]
    • Chosen: Put the guard logic in src/devops_cli/ci/gate_runner.py. The test imports a src/ module. The base lacks it, so the test fails on the base even when tests/ is overlaid.
    • Rejected: Test only tests/gate/runner.py. The overlay replaces the runner with the head version. The test then passes on the base.
    • Rejected: Prove the base failure by removing the guard by hand. The Fail-to-Pass Check needs an automated test that fails on the base. A manual run gives no check result.
  • Which status and output does the runner give for a gate module that supplies no case?: The runner writes one line to standard error for each empty module. It returns a non-zero status. (best practice) [sources: AGENTS.md, docs/TESTING.md]
    • Chosen: One line on standard error and a non-zero exit. It keeps standard output for case results. It makes the failure visible in the CI log.
    • Rejected: A raised exception with a traceback. A traceback hides the module name among frames. It reads as a crash, not as a gate result.
    • Rejected: A line on standard output. Case results use standard output. A reader of that output can miss the failure.
  • Where does the new test file sit?: The new test file is tests/ci/test_gate_runner.py. It sits in the mirror directory of src/devops_cli/ci/gate_runner.py. [sources: docs/TESTING.md]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    scope/ci
    source/agent
    on Nov 26, 2026
  2. dan-petty commented on Nov 26, 2026

    @dan-petty
    OwnerAuthor
  3. added
    status/new
    value/medium
    effort/low
    priority/p2-medium
    on Nov 26, 2026
  4. devops-cli-service commented on Nov 26, 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 (6)

    Tools considered:

    Searches run:

    • pytest exit code 5 no tests collected, results: 5
    • test runner exit non-zero when no tests collected, results: 5
    • "no tests collected" fail build CI guard empty test suite, results: 5
    • pytest "no tests ran" exit code 5 documentation, results: 5
    • bats-core fail when test file has no tests collected exit status, results: 5
    • docs.pytest.org exit codes no tests collected, results: 5

    Sources:

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

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  7. added
    owner/agent
    on Nov 29, 2026
  8. dan-petty commented on Nov 29, 2026

    @dan-petty
    OwnerAuthor

    Returning #7315 to New: it cannot pass CI as specified.

    1. Any PR modifying tests/gate/runner.py triggers changed.gate_modules = ('tests/gate/runner.py',) in src/devops_cli/ci/fail_to_pass.py:476-482,605.
    2. gate_row_of_module('tests/gate/runner.py') (src/devops_cli/ci/fail_to_pass.py:703-706) looks up 'runner' in CONST_GATE_MODULE_ROWS (src/devops_cli/config/constants.py:2730-2740), returns None, marks GateModuleReplay.refused = True (fail_to_pass.py:292-295), and causes FailToPassReport.satisfied (fail_to_pass.py:386) to return False (Fail-to-Pass Check runs on tests/gate/** per .github/workflows/fail-to-pass.yml:9).
    3. tests/ci/test_fail_to_pass.py:2525-2539 explicitly asserts that changing tests/gate/runner.py yields unowned_report.satisfied == False and unowned_report.gate_modules[0].refused == True.
    4. materialise_base_with_head_tests (src/devops_cli/ci/fail_to_pass.py:630-641) overlays HEAD's entire tests/ directory onto merge_base, so a pytest unit test in tests/ cannot fail on base in automated devops ci fail-to-pass replay.

    Possible prerequisite/refinement paths: distinguish shared harness helpers from unowned gate modules in fail_to_pass.py (and update tests/ci/test_fail_to_pass.py), or move the runner harness under src/ where fail-to-pass replays against merge_base.

  9. added
    status/new
    and removed
    status/ready
    on Nov 29, 2026
  10. added
    status/ready
    and removed
    status/new
    on Nov 29, 2026
  11. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  12. added
    status/in-progress
    and removed
    status/ready
    on Nov 29, 2026
  13. added
    status/in-review
    and removed
    status/in-progress
    on Nov 29, 2026
  14. removed
    status/in-review
    owner/agent
    on Nov 29, 2026
  15. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 16:50 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