Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/developers-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/rstest-bdd-users-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 5 additions & 1 deletion docs/users-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/app/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn std::error::Error + Send + Sync>),
/// Writing to the stream failed.
#[error("I/O error: {0}")]
Expand Down
10 changes: 5 additions & 5 deletions src/test_helpers/pool_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct PoolServerState {
/// One-shot flag controlling malformed-response coverage.
malformed_response_sent: Arc<AtomicBool>,
/// Response mode selected by the test case.
behavior: PoolServerBehavior,
behaviour: PoolServerBehavior,
}

impl PoolTestServer {
Expand All @@ -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<Self> {
pub async fn start_with_behavior(behaviour: PoolServerBehavior) -> std::io::Result<Self> {
let listener = TcpListener::bind("127.0.0.1:0").await?;
let addr = listener.local_addr()?;
let preamble_count = Arc::new(AtomicUsize::new(0));
Expand All @@ -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));
Expand Down Expand Up @@ -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));
}
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/extractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<TestMsg>::from_message_request(&request, &mut payload)
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/fragment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions tests/fixtures/message_assembly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down
1 change: 1 addition & 0 deletions tests/response/response_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
32 changes: 4 additions & 28 deletions typos.local.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -50,15 +34,7 @@ ignore = [
"Ser: Serializer",
"DecodeWith<Ser>",
"EncodeWith<Ser>",
"e\\.behavior\\ ==\\ PoolServerBehavior::MalformedFirstResponse",
"ior\\(behavior:\\ PoolServerBehavior\\)\\ \\->\\ std::io::Result<Sel",
"lTestServer::start_with_behavior\\(PoolServerBehavior::Mal",
"pub\\ async\\ fn\\ start_with_behavior\\(behavior:\\ PoolServerBeh",
"pub\\ enum\\ PoolServerBehavior\\ \\{",
"st\\(start_paused\\ =\\ true,\\ flavor\\ =\\ \"current_thread\"\\)\\]",
"tes\\(\\)\\.expect\\(\"failed\\ to\\ serialise\\ message\"\\);",
"with_behavior\\(PoolServerBehavior::EchoPong\\)\\.await",
"with_behavior\\(PoolServerBehavior::MalformedFirstResponse",
]

[files]
Expand Down
22 changes: 1 addition & 21 deletions typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,7 @@ extend-ignore-re = [
"HashiCorp",
"How to organise your Rust tests",
"Ser: Serializer",
"\\ \\ \\ \\ PoolServerBehavior,",
"\\ \\ \\ \\ \\ \\ 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,",
"\\ \\ 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\"\\)\\]",
Expand All @@ -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<Sel",
"lTestServer::start_with_behavior\\(PoolServerBehavior::Mal",
"mold --version",
"pub\\ async\\ fn\\ start_with_behavior\\(behavior:\\ PoolServerBeh",
"pub\\ enum\\ PoolServerBehavior\\ \\{",
"st\\(start_paused\\ =\\ true,\\ flavor\\ =\\ \"current_thread\"\\)\\]",
"sudo apt-get install -y mold",
"tes\\(\\)\\.expect\\(\"failed\\ to\\ serialise\\ message\"\\);",
"with_behavior\\(PoolServerBehavior::EchoPong\\)\\.await",
"with_behavior\\(PoolServerBehavior::MalformedFirstResponse",
]

[default.extend-words]
Expand Down
2 changes: 1 addition & 1 deletion wireframe_testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use wireframe_testing::{decode_frames, drive_with_bincode, logger};
#[tokio::test]
async fn drives_app() -> 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)?;
Expand Down
2 changes: 1 addition & 1 deletion wireframe_testing/src/helpers/tests/helper_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async fn drive_with_payloads_wraps_frames() -> io::Result<()> {
let (decoded, _) = serializer.deserialize::<Envelope>(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() {
Expand Down
Loading