diff --git a/docs/developers-guide.md b/docs/developers-guide.md index 9b17d2476..8e462e911 100644 --- a/docs/developers-guide.md +++ b/docs/developers-guide.md @@ -1434,12 +1434,12 @@ ordinary bare-word exceptions. Apart from the inline-code span, which the overlay masks until the shared dictionary does so itself, use one exact documented pattern per exception -rather than disabling a whole syntax class. The remaining exceptions are -limited to the `PoolServerBehavior` test-server fixture, the former -`BackoffConfig::normalised` public method, exact generic-bound fragments in RFC -0001, immutable en-GB diagnostic fixtures, and Tokio test attributes. Add a new -pattern only when a narrower correction or wording change would alter a public -API, external-tool key, formal name, or deliberately fixed diagnostic. +rather than disabling a whole syntax class. The remaining exceptions cover the +published `PoolServerBehavior` and `start_with_behavior` test-server names, the +former `BackoffConfig::normalised` public method, exact generic-bound fragments +in RFC 0001, and fixed external tool, CI and Tokio syntax. Add a new pattern +only when a narrower correction or wording change would alter a public API, +external-tool key, formal name, or deliberately fixed diagnostic. Eligible tracked files must remain readable UTF-8 text so the gate cannot silently omit them. Continuous integration installs Nixie 1.1.0 with Python diff --git a/docs/rstest-bdd-users-guide.md b/docs/rstest-bdd-users-guide.md index e97ead7a0..130308a79 100644 --- a/docs/rstest-bdd-users-guide.md +++ b/docs/rstest-bdd-users-guide.md @@ -762,7 +762,7 @@ fn counter() -> Counter { Counter::default() } -#[given("a counter initialised to 0")] +#[given("a counter initialized to 0")] fn init(counter: &mut Counter) { counter.value = 0; } diff --git a/docs/users-guide.md b/docs/users-guide.md index 2065e8c1e..8084b4fc5 100644 --- a/docs/users-guide.md +++ b/docs/users-guide.md @@ -208,7 +208,11 @@ through `on_connection_setup`, not in a rebuilt application graph. Serialization helpers `send_response` and `send_response_framed` (or `send_response_framed_with_codec` for custom codecs) return typed `SendError` variants when encoding or I/O fails, and the connection closes after ten -consecutive deserialization errors.[^6][^7] +consecutive deserialization errors.[^6][^7] Each `SendError` variant's +`Display` output starts with a fixed prefix: `serialization error:` for +`Serialize`, `I/O error:` for `Io`, and `codec error:` for `Codec`. Those +prefixes are stable and form the public diagnostic contract that callers may +match on; the source error text after them is not part of that contract. ### Custom frame codecs diff --git a/src/app/error.rs b/src/app/error.rs index 481fc43b0..c9b5298eb 100644 --- a/src/app/error.rs +++ b/src/app/error.rs @@ -11,7 +11,7 @@ use crate::codec::CodecError; #[non_exhaustive] pub enum SendError { /// Serialization failed. - #[error("serialisation error: {0}")] + #[error("serialization error: {0}")] Serialize(#[source] Box), /// Writing to the stream failed. #[error("I/O error: {0}")] diff --git a/src/test_helpers/pool_client.rs b/src/test_helpers/pool_client.rs index 688316910..af0c4b57e 100644 --- a/src/test_helpers/pool_client.rs +++ b/src/test_helpers/pool_client.rs @@ -75,7 +75,7 @@ struct PoolServerState { /// One-shot flag controlling malformed-response coverage. malformed_response_sent: Arc, /// Response mode selected by the test case. - behavior: PoolServerBehavior, + behaviour: PoolServerBehavior, } impl PoolTestServer { @@ -93,7 +93,7 @@ impl PoolTestServer { /// # Errors /// /// Returns an error if the test listener cannot bind to a local port. - pub async fn start_with_behavior(behavior: PoolServerBehavior) -> std::io::Result { + pub async fn start_with_behavior(behaviour: PoolServerBehavior) -> std::io::Result { let listener = TcpListener::bind("127.0.0.1:0").await?; let addr = listener.local_addr()?; let preamble_count = Arc::new(AtomicUsize::new(0)); @@ -102,7 +102,7 @@ impl PoolTestServer { preamble_count: preamble_count.clone(), connection_count: connection_count.clone(), malformed_response_sent: Arc::new(AtomicBool::new(false)), - behavior, + behaviour, }; let handle = tokio::spawn(run_pool_test_accept_loop(listener, state)); @@ -192,7 +192,7 @@ async fn run_pool_test_accept_loop(listener: TcpListener, state: PoolServerState preamble_count: state.preamble_count.clone(), connection_count: state.connection_count.clone(), malformed_response_sent: state.malformed_response_sent.clone(), - behavior: state.behavior, + behaviour: state.behaviour, }; tokio::spawn(handle_pool_test_connection(stream, state)); } @@ -224,7 +224,7 @@ async fn handle_pool_test_connection(mut stream: tokio::net::TcpStream, state: P break; }; - let payload = if state.behavior == PoolServerBehavior::MalformedFirstResponse + let payload = if state.behaviour == PoolServerBehavior::MalformedFirstResponse && !state.malformed_response_sent.swap(true, Ordering::SeqCst) { Vec::new() diff --git a/tests/extractor.rs b/tests/extractor.rs index b82bf7222..084c3044d 100644 --- a/tests/extractor.rs +++ b/tests/extractor.rs @@ -34,7 +34,7 @@ struct TestMsg(u8); #[rstest] fn message_extractor_parses_and_advances(request: MessageRequest) { let msg = TestMsg(42); - let bytes = msg.to_bytes().expect("failed to serialise message"); + let bytes = msg.to_bytes().expect("failed to serialize message"); let mut payload = Payload::new(bytes.as_slice()); let extracted = Message::::from_message_request(&request, &mut payload) diff --git a/tests/fixtures/fragment/mod.rs b/tests/fixtures/fragment/mod.rs index 6b8c20638..6443dcb42 100644 --- a/tests/fixtures/fragment/mod.rs +++ b/tests/fixtures/fragment/mod.rs @@ -184,13 +184,13 @@ impl FragmentWorld { fn series(&self) -> TestResult<&FragmentSeries> { self.series .as_ref() - .ok_or_else(|| "fragment series not initialised".into()) + .ok_or_else(|| "fragment series not initialized".into()) } fn series_mut(&mut self) -> TestResult<&mut FragmentSeries> { self.series .as_mut() - .ok_or_else(|| "fragment series not initialised".into()) + .ok_or_else(|| "fragment series not initialized".into()) } /// Assert that the latest fragment failed due to an index mismatch. diff --git a/tests/fixtures/message_assembly.rs b/tests/fixtures/message_assembly.rs index a01232715..ffeae4609 100644 --- a/tests/fixtures/message_assembly.rs +++ b/tests/fixtures/message_assembly.rs @@ -158,7 +158,7 @@ impl MessageAssemblyWorld { return Err("no pending first frame".into()); }; let Some(state) = self.state.as_mut() else { - return Err("state not initialised".into()); + return Err("state not initialized".into()); }; let Some(now) = self.current_time else { return Err("time not set".into()); @@ -184,7 +184,7 @@ impl MessageAssemblyWorld { /// Returns an error if state not initialized or time not set. pub fn accept_all_first_frames(&mut self) -> TestResult { let Some(state) = self.state.as_mut() else { - return Err("state not initialised".into()); + return Err("state not initialized".into()); }; let Some(now) = self.current_time else { return Err("time not set".into()); @@ -218,7 +218,7 @@ impl MessageAssemblyWorld { )] pub fn accept_continuation(&mut self, params: ContinuationFrameParams) -> TestResult { let Some(state) = self.state.as_mut() else { - return Err("state not initialised".into()); + return Err("state not initialized".into()); }; let Some(now) = self.current_time else { return Err("time not set".into()); @@ -257,7 +257,7 @@ impl MessageAssemblyWorld { /// Returns an error if state not initialized or time not set. pub fn purge_expired(&mut self) -> TestResult { let Some(state) = self.state.as_mut() else { - return Err("state not initialised".into()); + return Err("state not initialized".into()); }; let Some(now) = self.current_time else { return Err("time not set".into()); diff --git a/tests/response/response_errors.rs b/tests/response/response_errors.rs index ee7a08354..fba4a4a63 100644 --- a/tests/response/response_errors.rs +++ b/tests/response/response_errors.rs @@ -208,6 +208,7 @@ async fn send_response_returns_encode_error() { .await .expect_err("send_response should fail when encode errors"); assert_serialize_error(&err); + assert_eq!(err.to_string(), "serialization error: Other(\"fail\")"); } #[tokio::test] diff --git a/typos.local.toml b/typos.local.toml index 5f42f2228..5ae3b451f 100644 --- a/typos.local.toml +++ b/typos.local.toml @@ -11,37 +11,21 @@ accepted = [] [patterns] ignore = [ # Inline code spans are masked; the shared dictionary does not mask them yet. + '`[^`\n]+`', # Preserve the external Linux linker name only in its command and flag forms. "-Clink-arg=-fuse-ld=mold", "sudo apt-get install -y mold", "mold --version", # setup-rust's input that installs the linker. "install-mold", - '`[^`\n]+`', - # Public test-server fixture identifier. This preserves the externally - # visible helper name without accepting a bare word. + # Published test-server identifiers retain their public spellings. "\\bPoolServerBehavior\\b", - # Pool-test-server Rust fixtures. These exact source fragments preserve the - # public test helper's identifier and deliberately malformed response names. - "\\ \\ \\ \\ PoolServerBehavior,", + "\\bstart_with_behavior\\b", + # Fixed CI and Tokio identifiers keep their external spellings. "\\ \\ \\ \\ \\ \\ CARGO_TERM_COLOR:\\ always", - "\\ \\ \\ \\ \\ \\ \\ Self::start_with_behavior\\(PoolServerBehavior::Ech", - "\\ \\ \\ \\ \\ \\ \\ \\ PoolServerBehavior,", - "\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ behavior,", - "\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ behavior:\\ state\\.behavior,", - "\\ \\ \\ \\ \\ \\ \\ \\ behavior:\\ state\\.behavior,", - "\\ \\ \\ \\ \\ format!\\(\"failed\\ to\\ deserialise\\ envelope:\\ \\{error\\}\"\\),", - "\\ \\ \\ \\ \\#\\[error\\(\"serialisation\\ error:\\ \\{0\\}\"\\)\\]", - "\\ \\ \\ \\ behavior:\\ PoolServerBehavior,", - # Rust diagnostic fixtures use established en-GB messages that Typos must - # not reinterpret as prose corrections. - "\\ \\ return\\ Err\\(\"state\\ not\\ initialised\"\\.into\\(\\)\\);", - "\\ fn\\ start_with_behavior\\(behavior:\\ PoolServerBehavior\\)\\ \\->", - "\\ let\\ payload\\ =\\ if\\ state\\.behavior\\ ==\\ PoolServerBehavior::", "\\ reopened,\\ synchronize,\\ labeled,\\ ready_for_review\\]", "\\#\\[tokio::test\\(flavor\\ =\\ \"current_thread\",\\ sta", "\\#\\[tokio::test\\(flavor\\ =\\ \"current_thread\"\\)\\]", - "\\|\\|\\ \"fragment\\ series\\ not\\ initialised\"\\.into\\(\\)\\)", # Migration documentation records the immutable former public method name. "BackoffConfig::normalised", # RFC generic-bound examples use the declared `Ser` parameter only in these @@ -50,15 +34,7 @@ ignore = [ "Ser: Serializer", "DecodeWith", "EncodeWith", - "e\\.behavior\\ ==\\ PoolServerBehavior::MalformedFirstResponse", - "ior\\(behavior:\\ PoolServerBehavior\\)\\ \\->\\ std::io::Result", - "\\ let\\ payload\\ =\\ if\\ state\\.behavior\\ ==\\ PoolServerBehavior::", "\\ reopened,\\ synchronize,\\ labeled,\\ ready_for_review\\]", "\\#\\[tokio::test\\(flavor\\ =\\ \"current_thread\",\\ sta", "\\#\\[tokio::test\\(flavor\\ =\\ \"current_thread\"\\)\\]", @@ -66,25 +54,17 @@ extend-ignore-re = [ "\\bcolor-(?:mix|contrast)\\b", "\\bflavor = ", "\\brust-analyzer\\b", + "\\bstart_with_behavior\\b", "\\{COLOR\\}", "\\{color\\}", - "\\|\\|\\ \"fragment\\ series\\ not\\ initialised\"\\.into\\(\\)\\)", "`[^`\\n]+`", "`color`", "`var\\.iamge_id` instead of `var\\.image_id`", "currentColor", - "e\\.behavior\\ ==\\ PoolServerBehavior::MalformedFirstResponse", "install-mold", - "ior\\(behavior:\\ PoolServerBehavior\\)\\ \\->\\ std::io::Result std::io::Result<()> { let _log_guard = logger(); - let app = WireframeApp::new().expect("failed to initialise app"); + let app = WireframeApp::new().expect("failed to initialize app"); let raw = drive_with_bincode(app, 42u8).await?; let frames = decode_frames(&raw)?; diff --git a/wireframe_testing/src/helpers/tests/helper_tests.rs b/wireframe_testing/src/helpers/tests/helper_tests.rs index 9f5fa9f9c..3042f7ba1 100644 --- a/wireframe_testing/src/helpers/tests/helper_tests.rs +++ b/wireframe_testing/src/helpers/tests/helper_tests.rs @@ -81,7 +81,7 @@ async fn drive_with_payloads_wraps_frames() -> io::Result<()> { let (decoded, _) = serializer.deserialize::(first).map_err(|error| { io::Error::new( io::ErrorKind::InvalidData, - format!("failed to deserialise envelope: {error}"), + format!("failed to deserialize envelope: {error}"), ) })?; if decoded.payload_bytes() != payload.as_slice() {