Skip to content

fix(test): test run names its timeout, no traceback #4926

Closed

Description

@dan-petty

Problem Description

devops test run --changed prints a Python traceback when pytest runs longer than the subprocess timeout. run_test_cmd (src/devops_cli/commands/test_cmd.py:195) calls run_subprocess(cmd, cwd=repo_root, check=False), and subprocess.TimeoutExpired goes up through core/process.py with no handler. The output is about 480 lines: the traceback and the full pytest argument list of 421 test modules. The command does not say which limit stopped it or what to do.

Reproduction Steps

  1. On a host with a high load (load average 42 on 16 cores), change about 50 files on a branch, so that the narrowed run selects 421 test modules.
  2. Run uv run devops test run --changed.
  3. After 1800 s, the command stops.

Expected vs Actual Behavior

Expected: one error line that names the timeout (1800 s) and the setting or option that changes it, and exit 1, as other devops commands do for a DevOpsCLIError.

Actual: a Rich traceback that ends in TimeoutExpired: Command '['uv', 'run', 'pytest', ...]' timed out after 1800.0 seconds, with every test path of the argument list.

Environment Diagnostics

devops-cli at origin/main 9208717 plus the branch of #4835, Python 3.14, devcontainer.

Logs, Traces, or Terminal Output

Frames: core/cli.py:221 traced_fn -> commands/test_cmd.py:195 run_test_cmd -> core/process.py:918 run_subprocess -> core/process.py:655 run -> subprocess.py:1268 _check_timeout.

Related: #4683 and #4775 give devops ci rows their own time limits; they do not cover devops test run.

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

Proposed design

Problem statement

The devops test run --changed command prints a Rich traceback when pytest runs longer than the subprocess timeout. The traceback ends in TimeoutExpired and shows the full 421-module argument list, but it does not name the 1800-second limit or the option that changes it. The command must report one DevOpsCLIError line and exit 1.

Acceptance criteria

Requirement: Timeout error line

The devops test run command SHALL report a pytest subprocess timeout as one DevOpsCLIError line and exit with status 1.

Scenario: Changed run exceeds timeout

  • WHEN The pytest subprocess exceeds the test-run timeout.
  • THEN The command prints one error line that names the timeout in seconds and the --timeout option, prints no traceback, and exits 1.

Requirement: Configurable timeout

The devops test run command SHALL use the --timeout option, default 1800 seconds, as the pytest subprocess timeout.

Scenario: Custom timeout value

  • WHEN A user runs devops test run --timeout 60.
  • THEN The command passes 60 seconds as the timeout to run_subprocess.

Requirement: Effective timeout in message

The timeout error line SHALL state the effective timeout value that stopped the run.

Scenario: Non-default timeout in error

  • WHEN The test run uses a timeout of 60 seconds and the subprocess exceeds it.
  • THEN The error line states 60 seconds, not 1800 seconds.

Requirement: Non-timeout behavior

The command SHALL keep the existing output and exit status for a pytest failure that is not a timeout.

Scenario: Pytest fails before timeout

  • WHEN The pytest subprocess exits with a non-zero status before the timeout.
  • THEN The command reports the pytest result as before and prints no timeout error.

Existing Tool Considered

The 2026-11-15 alternatives check found no open, maintained tool that converts subprocess.TimeoutExpired into this project's DevOpsCLIError or that knows the --timeout option. The fix is local code in run_test_cmd. The written cost is about 1,500 tokens to build, keep and fix that code, and less than one hour.

Key questions

  • Where does subprocess.TimeoutExpired escape run_test_cmd?: It escapes from the run_subprocess call at src/devops_cli/commands/test_cmd.py:195; src/devops_cli/core/process.py:918 calls run at src/devops_cli/core/process.py:655, which lets subprocess.TimeoutExpired propagate. [sources: src/devops_cli/commands/test_cmd.py:195, src/devops_cli/core/process.py:918, src/devops_cli/core/process.py:655]
  • How should the command report a timeout?: Catch subprocess.TimeoutExpired in run_test_cmd and raise DevOpsCLIError with the effective timeout and the --timeout option. The CLI exit seam prints one error line and exits with the error code. (best practice) [sources: ARCHITECTURE.md:173, src/devops_cli/exceptions/base.py:19, src/devops_cli/commands/test_cmd.py:195]
    • Rejected: Let the traceback propagate. It prints 480 lines and does not name the limit or the option.
    • Rejected: Catch and print directly. It bypasses the one exit seam and the error exit code.
    • Chosen: Raise DevOpsCLIError. The exit seam prints one line, escapes markup, and exits 1 with no traceback.
  • Which option changes the test-run timeout?: Add or use the --timeout option of devops test run, default 1800 seconds, and pass its value to run_subprocess. (best practice) [sources: src/devops_cli/commands/test_cmd.py:139, src/devops_cli/commands/test_cmd.py:195, src/devops_cli/core/process.py:918]
    • Chosen: Use a --timeout option. It is explicit, testable, and the error can name it.
    • Rejected: Use a fixed 1800-second default. A user cannot change the limit for this command.
    • Rejected: Use a config setting with no CLI option. No source names such a setting, and the error cannot name a concrete control.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    status/new
    value/medium
    effort/low
    on Nov 12, 2026
  2. dan-petty commented on Nov 12, 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/bug. The fix prefix of the title gives the type.
    • Scope: none. The title has the scope test, and .github/labels.yml declares no scope/test label. Add the label to the file to give the scope to this item.
    • Priority: P2-Medium. The command still stops at the timeout; the defect is only the 480-line traceback instead of a one-line error.
    • Value: Medium. A 480-line traceback with 421 test paths is hard to read; one clean line with the timeout value and the option to change it is a clear UX gain.
    • Effort: Low. Catch TimeoutExpired at test_cmd.py:195 and raise DevOpsCLIError with the timeout value and the setting name.
    • Related: feat(ci): devops ci ends each row at a time limit #4775, which asks for a different change. Both handle subprocess timeouts in core/process.py, but #4775 adds per-row time limits for devops ci while the candidate fixes the error message for devops test run.
  3. added
    priority/p2-medium
    on Nov 12, 2026
  4. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches turned up no open tool or library that converts a subprocess.TimeoutExpired from a pytest run into a one-line CLI error, and none that knows this project's own setting name for the test-run timeout. The intake reply itself puts the fix at commands/test_cmd.py:195: catch the exception and raise DevOpsCLIError with the timeout value and the setting, which only the project's own code can name.

    Tool: none found

    Lacks:

    • No library turns subprocess.TimeoutExpired from run_subprocess into the project's DevOpsCLIError with exit 1
    • No library knows the devops-cli setting or option that changes the 1800 s test-run limit, so it cannot name it in the error line
    • Suppressing or reformatting the traceback has to happen at the run_test_cmd call site in the project's own code

    Searches run:

    • pytest plugin catch subprocess timeout error message instead of traceback, results: 5
    • python library convert subprocess.TimeoutExpired into clean user error message, results: 5
    • python typer rich catch exception print clean error line exit 1 library, results: 5
    • pytest-timeout plugin fails test run with clear timeout message, results: 5
    • python library human-readable duration formatting humanize, results: 5
    • pytest-timeout PyPI plugin, results: 5
    • "pytest-timeout" github repository, results: 5

    Checked on 2026-11-15. 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 16, 2026
  6. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

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

  7. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    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 16:28 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-mediumsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions