Skip to content

test(cli): cover JSON export progress behavior under CI vs TTY#237

Draft
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/missing-test-coverage-4afd
Draft

test(cli): cover JSON export progress behavior under CI vs TTY#237
cursor[bot] wants to merge 1 commit into
masterfrom
cursor/missing-test-coverage-4afd

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented May 10, 2026

Description

Adds regression tests for resource_json installation/directory export progress reporting: CI and GitHub Actions must disable carriage-return stderr updates so milestones appear in structured logs; interactive TTY sessions still use \r live updates on the progress stream.

Type of Change

  • ✅ Test addition or update

Package(s) Affected

  • PyKotor (core library)

Risky behavior now covered

  • _supports_live_progress: CI / GITHUB_ACTIONS truthy values force live stderr updates off even when the stream reports a TTY, matching automation-friendly behavior from commit c7e573d1d (fix(json-export): log progress when automated).
  • _ExportProgressReporter: With CI set, progress uses logger.info and never writes to the progress stream (would break if someone routed live \r output in CI again). Without CI, TTY streams receive carriage-return progress lines and the named test logger receives no duplicate INFO lines for that path.

Test files added/updated

  • Libraries/PyKotor/tests/cli/test_json_commands.py

Why these tests materially reduce regression risk

Large installation to-json exports are often run in CI; if live stderr rendering were re-enabled there, percentage progress would bypass log aggregators and caplog-style assertions. These tests pin the intended split between logger-based milestones (CI) and TTY streaming (local dev), so a refactor of _ExportProgressReporter cannot silently drop CI-visible progress again.

Testing

Ran (from Libraries/PyKotor):

uv run pytest --import-mode=importlib -m "not gui and not slow" --rootdir=/workspace/Libraries/PyKotor -o addopts= tests/cli/test_json_commands.py::test_supports_live_progress_false_when_ci_env_truthy tests/cli/test_json_commands.py::test_supports_live_progress_false_when_github_actions_truthy tests/cli/test_json_commands.py::test_export_progress_reporter_logs_to_logger_when_ci_disables_live_updates tests/cli/test_json_commands.py::test_export_progress_reporter_writes_carriage_returns_when_not_ci_and_stream_is_tty -v

All four tests passed. Tests are deterministic (monkeypatched env, fake TTY, standard logging.Logger + caplog—avoids RobustLogger without a configured backing logger, which would raise during info).

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
Open in Web View Automation 

Co-authored-by: Boden <th3w1zard1@users.noreply.github.com>
@github-actions github-actions Bot added python Pull requests that update python code libraries size/S Small PR (30-100 lines) labels May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libraries python Pull requests that update python code size/S Small PR (30-100 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant