Skip to content

Tests: Improve shell interoperability - #577

Draft
tony wants to merge 7 commits into
masterfrom
test-terminal-interoperability
Draft

tony wants to merge 7 commits into
masterfrom
test-terminal-interoperability

Conversation

@tony

@tony tony commented Feb 23, 2025 •

Copy link
Copy Markdown
Member

Note

Master through v0.70.0 resolved the session and split-window environment waits in #922 (0.68.0), raised the tmux floor to 3.3a in #888 (0.65.0), and switched static type checking to ty (uv run ty check) and Ruff ANN in #682 (0.70.0). Remaining shell-readiness test updates are tracked in #484 and #907.

Summary by Sourcery

Improve shell interoperability in tests by using a consistent prompt across shells and adding retry logic to wait for the shell to be ready and for the command output to be available before asserting the pane contents.

Tests:

  • Improve shell interoperability in tests by using PROMPT_COMMAND and PS1 to set a consistent prompt across shells.
  • Add retry logic to wait for the shell to be ready and for the command output to be available before asserting the pane contents.

@sourcery-ai

sourcery-ai Bot commented Feb 23, 2025 •

Copy link
Copy Markdown

Reviewer's Guide by Sourcery

The pull request improves the reliability of the test_capture_pane test by ensuring consistent shell behavior across different environments. It achieves this by setting a custom prompt using PROMPT_COMMAND and PS1, and then waiting for the shell to become ready before sending commands. It also waits for the command output before asserting the final state.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Improved shell interoperability in test_capture_pane by setting a consistent prompt and waiting for the shell to be ready.
  • Used PROMPT_COMMAND and PS1 to set a consistent prompt across shells.
  • Added a wait_for_prompt function to wait for the shell to be ready with the custom prompt.
  • Added a wait_for_output function to wait for the command output and the new prompt.
  • Modified assertions to check for the custom prompt and command output.
tests/test_pane.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codecov

codecov Bot commented Feb 23, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.05%. Comparing base (6c92651) to head (1defb8f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #577      +/-   ##
==========================================
+ Coverage   61.99%   62.05%   +0.05%     
==========================================
  Files          29       29              
  Lines        5091     5091              
  Branches     1082     1082              
==========================================
+ Hits         3156     3159       +3     
+ Misses       1595     1592       -3     
  Partials      340      340              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tony
tony force-pushed the test-terminal-interoperability branch 4 times, most recently from ac631e0 to 82da140 Compare February 25, 2025 22:16
@tony
tony force-pushed the master branch 4 times, most recently from 0188aed to ea5b0c4 Compare April 12, 2025 12:08
@tony
tony force-pushed the test-terminal-interoperability branch from 82da140 to 78c656b Compare April 26, 2026 11:34
@tony
tony force-pushed the test-terminal-interoperability branch from 78c656b to 1d71c36 Compare May 10, 2026 15:57
@tony
tony force-pushed the test-terminal-interoperability branch from 1d71c36 to 7a47177 Compare May 30, 2026 12:51
@tony
tony force-pushed the test-terminal-interoperability branch from 7a47177 to 32d14ea Compare July 18, 2026 11:02
@tony
tony force-pushed the test-terminal-interoperability branch from 32d14ea to 2d87270 Compare November 7, 2026 02:18
@tony
tony force-pushed the test-terminal-interoperability branch 5 times, most recently from 8fe9bb8 to cb80408 Compare November 25, 2026 08:28
@tony
tony force-pushed the test-terminal-interoperability branch from 7732a6c to 081a38e Compare November 28, 2026 12:49
@tony tony added pytest-plugin area: observation Waits, capture, snapshots, subscriptions labels Nov 29, 2026
@tony
tony force-pushed the test-terminal-interoperability branch from 081a38e to 91b67a6 Compare November 29, 2026 03:10
tony added 3 commits November 29, 2026 18:59
why: Tests were failing when using fish shell due to prompt differences

what:
- Use PROMPT_COMMAND='' to clear shell-specific prompt commands
- Set custom PS1='READY>' that works across shells
- Add retry logic to wait for prompt and command output
- Make assertions more flexible by checking content not exact matches
why: Test was flaky due to timing issues with shell initialization

what:
- Add small delay after window creation
- Add error handling around capture_pane calls
- Increase retry timeouts from 1s to 2s
- Add more comprehensive output checks
- Add check for non-empty pane contents
Add setup_shell_window helper function to standardize shell setup in tests:
Set consistent shell environment and prompt, add robust waiting for shell
readiness, handle environment variables consistently, prevent shell-specific
prompt modifications.

Update test_new_window_with_environment to use new helper:
Add proper waiting for command output, fix linting issues with loop variables,
make tests more reliable against timing issues.
tony added 4 commits November 29, 2026 18:59
Catch exc.LibTmuxException instead of bare Exception in retry_until
shell-readiness callbacks across test_pane, test_session, and test_window
so Ruff BLE001 passes and non-tmux errors propagate.
why: Environment tests must wait for both the echoed value line and the
next READY> prompt (#922), and Pane.send_keys doctest should not catch
bare Exception or race before command output renders (#902).

what:
- Assert capture_pane()[-2:] == [expected, "READY>"] in session and
  window environment tests
- Wait for rendered output and READY> in Pane.send_keys doctest without
  catching bare Exception
- Use NumPy docstrings on setup_shell_window helpers
@tony
tony force-pushed the test-terminal-interoperability branch from 91b67a6 to 1defb8f Compare November 30, 2026 01:00

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: observation Waits, capture, snapshots, subscriptions pytest-plugin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant