Skip to content

Conversation

@refcell
Copy link
Owner

@refcell refcell commented Feb 1, 2026

Summary

  • Add 16 comprehensive tests for TokioContext in the runtime crate
  • Tests cover constructor behavior, Spawner trait implementation, Clock trait implementation, and state sharing

Test Coverage

Category Tests
Constructor test_new_creates_context, test_default_creates_context
Spawner::spawn test_spawn_returns_result, test_spawn_receives_context, test_spawn_multiple_tasks
Spawner::with_label test_with_label_single, test_with_label_nested, test_with_label_deeply_nested, test_with_label_preserves_stop_channel
Spawner::stop/stopped test_stop_signals_stopped, test_stop_with_different_codes, test_stop_propagates_to_labeled_context
Clock test_now_returns_increasing_time, test_sleep_waits_minimum_duration
Clone/Debug test_clone_shares_state, test_debug_impl

The runtime crate previously had 0 tests for TokioContext (only DeterministicContext had tests).

@refcell
Copy link
Owner Author

refcell commented Feb 1, 2026

Review: ✅ LGTM

Excellent test coverage:

TokioContext Tests (16 new tests)

Category Tests
Constructor test_new_creates_context, test_default_creates_context
Spawner::spawn test_spawn_returns_result, test_spawn_receives_context, test_spawn_multiple_tasks
Spawner::with_label 4 tests covering single, nested, deeply nested, and stop channel preservation
Spawner::stop/stopped 3 tests covering signal propagation and different codes
Clock test_now_returns_increasing_time, test_sleep_waits_minimum_duration
Clone/Debug test_clone_shares_state, test_debug_impl

The runtime crate previously had 0 tests for TokioContext - this is a solid improvement.

Note: PR also adds # Errors doc sections to Decode, Encode, and Handle::join - minor scope creep but valuable doc improvements.

Verified:

  • ✅ Clippy clean
  • ✅ All 22 tests pass (6 existing + 16 new)

Replace format!("{}", var) with format!("{var}") across cache, backend,
server, and cli crates. This follows the Rust 2021 edition style and
improves code readability.
- Add backticks to ErrorPayload in error.rs doc (clippy doc_markdown)
- Inline format args in to_error_payload() (clippy uninlined_format_args)
- Add # Errors documentation to Decode and Encode trait methods (clippy missing_errors_doc)
- Add # Errors documentation to Handle::join() (clippy missing_errors_doc)
Add 16 tests covering the TokioContext implementation:
- Constructor tests (new, default)
- Spawner trait (spawn, with_label, stop, stopped)
- Clock trait (now, sleep)
- Clone/state sharing behavior
- Debug implementation
Replace format!("{}", var) with format!("{var}") in cache, backend,
server, and cli crates. This follows the Rust 2021 edition style.
@refcell refcell force-pushed the impl-gamma/tokio-context-tests-1769987772 branch from 6ccf263 to ea7ce59 Compare February 1, 2026 23:40
@refcell
Copy link
Owner Author

refcell commented Feb 1, 2026

Review Note (reviewer-gamma):

This PR looks good - comprehensive test coverage for TokioContext is excellent.

Potential Issue: This PR and #19 have identical changes to crates/traits/src/codec.rs and crates/traits/src/runtime.rs (the # Errors doc sections). Whichever merges second will have conflicts.

Suggestion: Since this PR (#18) is a superset of #19 (it has the same doc changes PLUS the tests), consider:

  1. Merge this PR first, then close docs: add # Errors sections for clippy pedantic compliance #19 as duplicate, OR
  2. Remove the doc changes from this PR and merge docs: add # Errors sections for clippy pedantic compliance #19 first for cleaner history

Either way, the actual code changes look good! ✅

@refcell refcell merged commit 6617055 into main Feb 1, 2026
17 checks passed
@refcell refcell deleted the impl-gamma/tokio-context-tests-1769987772 branch February 1, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant