Improve naming of Error variants in iced_test

This commit is contained in:
Héctor Ramón Jiménez 2025-08-27 06:18:23 +02:00
parent ed873514e5
commit 1c54f5e3e9
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
3 changed files with 9 additions and 10 deletions

View file

@ -10,9 +10,9 @@ use std::sync::Arc;
pub enum Error { pub enum Error {
/// No matching widget was found for the [`Selector`](crate::Selector). /// No matching widget was found for the [`Selector`](crate::Selector).
#[error("no matching widget was found for the selector: {selector}")] #[error("no matching widget was found for the selector: {selector}")]
NotFound { selector: String }, SelectorNotFound { selector: String },
#[error("the matching target is not visible: {target:?}")] #[error("the matching target is not visible: {target:?}")]
NotVisible { TargetNotVisible {
target: Arc<dyn std::fmt::Debug + Send + Sync>, target: Arc<dyn std::fmt::Debug + Send + Sync>,
}, },
/// An IO operation failed. /// An IO operation failed.
@ -30,7 +30,7 @@ pub enum Error {
error: ice::ParseError, error: ice::ParseError,
}, },
#[error("the ice test ({file}) failed")] #[error("the ice test ({file}) failed")]
IceFailed { IceTestingFailed {
file: PathBuf, file: PathBuf,
instruction: Instruction, instruction: Instruction,
}, },

View file

@ -180,16 +180,15 @@ pub fn run(
let mut instructions = ice.instructions.into_iter(); let mut instructions = ice.instructions.into_iter();
loop { loop {
let Some(event) = executor::block_on(receiver.next()) else { let event = executor::block_on(receiver.next())
panic!("emulator runtime stopped unexpectedly"); .expect("emulator runtime should never stop on its own");
};
match event { match event {
emulator::Event::Action(action) => { emulator::Event::Action(action) => {
emulator.perform(&program, action); emulator.perform(&program, action);
} }
emulator::Event::Failed(instruction) => { emulator::Event::Failed(instruction) => {
return Err(Error::IceFailed { return Err(Error::IceTestingFailed {
file: file.path().to_path_buf(), file: file.path().to_path_buf(),
instruction, instruction,
}); });

View file

@ -118,11 +118,11 @@ where
match operation.finish() { match operation.finish() {
widget::operation::Outcome::Some(output) => { widget::operation::Outcome::Some(output) => {
output.ok_or(Error::NotFound { output.ok_or(Error::SelectorNotFound {
selector: description, selector: description,
}) })
} }
_ => Err(Error::NotFound { _ => Err(Error::SelectorNotFound {
selector: description, selector: description,
}), }),
} }
@ -148,7 +148,7 @@ where
let target = self.find(selector)?; let target = self.find(selector)?;
let Some(visible_bounds) = target.visible_bounds() else { let Some(visible_bounds) = target.visible_bounds() else {
return Err(Error::NotVisible { return Err(Error::TargetNotVisible {
target: Arc::new(target), target: Arc::new(target),
}); });
}; };