Skip to content

Commit aba2cd9

Browse files
committed
!squash waiter.md docs
1 parent af1e013 commit aba2cd9

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

docs/test-helpers/waiter.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ The waiter module provides utilities for waiting on specific content to appear i
99
- **Composable Waiting**: Wait for any of multiple conditions or all conditions to be met
1010
- **Flexible Timeout Handling**: Configure timeout behavior and error handling to suit your needs
1111
- **Shell Prompt Detection**: Easily wait for shell readiness with built-in prompt detection
12+
- **Robust Error Handling**: Improved exception handling and result reporting
13+
- **Clean Code**: Well-formatted, linted code with proper type annotations
1214

1315
## Basic Concepts
1416

@@ -52,12 +54,14 @@ Control how long to wait and what happens when a timeout occurs:
5254

5355
### Waiting for Shell Readiness
5456

55-
A common use case is waiting for a shell prompt to appear, indicating the command has completed:
57+
A common use case is waiting for a shell prompt to appear, indicating the command has completed. The example below uses a regular expression to match common shell prompt characters (`$`, `%`, `>`, `#`):
5658

5759
```{literalinclude} ../../tests/examples/test/waiter/test_wait_until_ready.py
5860
:language: python
5961
```
6062

63+
> Note: This test is skipped in CI environments due to timing issues but works well for local development.
64+
6165
## Fluent API (Playwright-inspired)
6266

6367
For a more expressive and chainable API, you can use the fluent interface provided by the `PaneContentWaiter` class:
@@ -153,3 +157,25 @@ These methods configure the waiter and return a new waiter with the updated conf
153157
* `elapsed_time`: The time elapsed during the wait
154158
* `error`: The error message, if any
155159
* `matched_pattern_index`: The index of the matched pattern (for wait_for_any_content)
160+
161+
## Implementation Notes
162+
163+
### Error Handling
164+
165+
The waiting functions are designed to be robust and handle timing and error conditions gracefully:
166+
167+
- All wait functions properly calculate elapsed time for performance tracking
168+
- Functions handle exceptions consistently and provide clear error messages
169+
- Proper handling of return values ensures consistent behavior whether or not raises=True
170+
171+
### Type Safety
172+
173+
The waiter module is fully type-annotated to ensure compatibility with static type checkers:
174+
175+
- All functions include proper type hints for parameters and return values
176+
- The ContentMatchType enum ensures that only valid match types are used
177+
- Combined with runtime checks, this prevents type-related errors during testing
178+
179+
### Example Usage in Documentation
180+
181+
All examples in this documentation are actual test files from the libtmux test suite. The examples are included using `literalinclude` directives, ensuring that the documentation remains synchronized with the actual code.

0 commit comments

Comments
 (0)