Skip to content

fix(cli): Print the elapsed line only on a terminal - #5554

Merged
dan-petty merged 4 commits into
mainfrom
fix/5448-print-the-elapsed-line-only-when
Nov 13, 2026
Merged

dan-petty merged 4 commits into
mainfrom
fix/5448-print-the-elapsed-line-only-when

Conversation

@devops-cli-service

@devops-cli-service devops-cli-service Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Each devops command writes an Elapsed: line to stderr at exit, also when stderr is a pipe, as src/devops_cli/main.py:32:print_muted(f"Elapsed: {format_duration(elapsed)}", to_stderr=True) shows. An agent tool captures stdout and stderr together, so the line enters the agent context on almost every call, and a 2>&1 JSON pipe fails with JSONDecodeError: Extra data. #5448 keeps the line for a person at a terminal and removes it from every other stderr.

The hook is now public as print_elapsed, so two in-process tests can import it. The changed-line coverage gate does not measure the child-process tests. The archived design.md records this decision.

Closes #5448

Change: openspec/changes/archive/2026-11-13-5448-print-the-elapsed-line-only-when/

@devops-cli-service
devops-cli-service Bot force-pushed the fix/5448-print-the-elapsed-line-only-when branch 2 times, most recently from e95391b to 921cbb9 Compare November 13, 2026 21:08
@devops-cli-service

Copy link
Copy Markdown
Contributor Author

The steps of the job:

Step Status Attempts Tokens in/out Last failing command
group 1 done 1 12530619/61833 pytest on base: tests/invariants/test_cli_elapsed_line.py
group 2 done 1 2440186/9446 -
group 3 done 1 582434/4494 ! git grep -n -F Elapsed: CONTRIBUTING.md
  • scoped check pre-push: passed, 8 s
  • scoped check static: passed, 23 s
  • scoped check tests: passed, 33 s
  • scoped check tests: the changed files select more than 30 test modules, so only the changed test modules ran. The required checks of CI run the others
  • fail-to-pass of group 1: fails on the base commit. Tests that fail on the base commit: tests.invariants.test_cli_elapsed_line::test_force_color_with_a_pipe_gets_no_elapsed_line, tests.invariants.test_cli_elapsed_line::test_a_pipe_gets_no_elapsed_line, tests.invariants.test_cli_elapsed_line::test_a_pipe_stream_gets_no_elapsed_line, tests.invariants.test_cli_elapsed_line::test_a_terminal_stream_gets_the_elapsed_line.
  • verify of group 2: uv run devops ci test tests/telemetry/test_telemetry_instruments.py exits 0.
================================================================================================================== test session starts ===================================================================================================================
platform linux -- Python 3.14.10, pytest-9.2.0, pluggy-1.7.0
rootdir: /home/devops/.data/agent/worktrees/w-5448
configfile: pyproject.toml
plugins: xdist-3.8.0, cov-7.1.0, asyncio-1.4.1.post1, hypothesis-6.170.15, syrupy-7.0.0, time-machine-3.6.0, mock-3.17.0, anyio-4.16.0, platformdirs-4.14.5, timeout-2.4.0
asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
timeout: 600.0s
timeout method: signal
timeout func_only: False
collected 62 items

tests/telemetry/test_telemetry_instruments.py ..............................................................                                                                                                                                       [100%]

================================================================================================================== 62 passed in 12.21s ===================================================================================================================
Bytecode compiled 19311 files in 446ms
Bytecode compiled 19311 files in 472ms
/home/devops/.data/agent/worktrees/w-5448/.venv/lib/python3.14/site-packages/pytest_asyncio/plugin.py:300: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset.
The event loop scope for asynchronous fixtures will default to the "fixture" caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to "function" scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session"

  warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))
  • verify of group 3: ! git grep -n -F Elapsed: CONTRIBUTING.md exits 1.

  • verify of group 3: uv run devops ci docs exits 0.
\u2139 Quality gate root: /home/devops/.data/agent/worktrees/w-5448
\u2713 All documentation files are up to date.
Bytecode compiled 19311 files in 489ms
Bytecode compiled 19311 files in 437ms

@devops-cli-service devops-cli-service Bot added type/bug Type bug: the code does not do what it must scope/cli Core CLI framework, Typer subcommands, options, and tables labels Nov 13, 2026
@devops-cli-service
devops-cli-service Bot marked this pull request as ready for review November 13, 2026 21:24
@dan-petty
dan-petty force-pushed the fix/5448-print-the-elapsed-line-only-when branch from 50427b1 to 01de161 Compare November 13, 2026 22:00
@dan-petty
dan-petty enabled auto-merge (squash) November 13, 2026 22:04
@dan-petty
dan-petty merged commit 5dc5882 into main Nov 13, 2026
27 checks passed
@dan-petty
dan-petty deleted the fix/5448-print-the-elapsed-line-only-when branch November 13, 2026 22:06
dan-petty pushed a commit that referenced this pull request Nov 13, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.133.0](v0.132.1...v0.133.0)
(2026-11-13)


### Features

* **roadmap:** run each stage item in its own Job
([#5559](#5559))
([b771fc4](b771fc4))


### Bug Fixes

* **cli:** Print the elapsed line only on a terminal
([#5554](#5554))
([5dc5882](5dc5882))
* **roadmap:** only blocker and major review findings block a plan
([#5557](#5557))
([75d45b5](75d45b5))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/cli Core CLI framework, Typer subcommands, options, and tables type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): print the Elapsed line only when stderr is a terminal

1 participant