This commit is contained in:
Adrian Heine 2020-10-17 23:44:52 +02:00
parent b53267f406
commit da98bfba8c
20 changed files with 80 additions and 61 deletions

View file

@ -7,5 +7,6 @@ pub use symbol_runner::{
SymbolRunner,
};
mod runnable;
#[allow(clippy::module_inception)]
mod setup;
pub use setup::SetupFacade as Setup;

View file

@ -16,6 +16,7 @@ pub trait Runnable {
}
#[async_trait(?Send)]
#[allow(clippy::use_self)]
impl<S> Runnable for S
where
Self: Symbol + Debug,
@ -32,6 +33,7 @@ where
macro_rules! runnable_for_tuple {
( $($name:ident)* ) => (
#[allow(clippy::let_unit_value)]
#[async_trait(?Send)]
#[allow(non_snake_case)]
impl<$($name: Symbol + Debug,)*> Runnable for ($($name,)*) {
@ -117,7 +119,7 @@ mod test {
async fn run_symbol<S: Symbol + Debug, L: Logger>(
&self,
symbol: &S,
logger: &L,
_logger: &L,
force: bool,
) -> Result<bool, Box<dyn Error>> {
let run = force || !symbol.target_reached().await?;

View file

@ -201,7 +201,7 @@ mod test {
async fn run_symbol<S: Symbol + Debug, L: Logger>(
&self,
symbol: &S,
logger: &L,
_logger: &L,
force: bool,
) -> Result<bool, Box<dyn Error>> {
let run = force || !symbol.target_reached().await?;
@ -239,10 +239,12 @@ mod test {
#[derive(Clone)]
struct Artifacts;
impl<V> FromArtifact<TestResource<V>> for Artifacts {
fn from_artifact(from: ()) -> Self {
fn from_artifact(_from: ()) -> Self {
Self
}
#[allow(clippy::unused_unit)]
fn into_artifact(self) -> () {
#[allow(clippy::unused_unit)]
()
}
}

View file

@ -17,27 +17,14 @@ pub trait SymbolRunner {
) -> Result<bool, Box<dyn Error>>;
}
#[derive(Debug)]
pub enum SymbolRunError {
Symbol(Box<dyn Error>),
ExecuteDidNotReach(()),
}
#[derive(Debug, Default)]
pub struct ExecuteDidNotReachError;
impl Error for SymbolRunError {
fn cause(&self) -> Option<&dyn Error> {
match self {
Self::Symbol(ref e) => Some(&**e),
Self::ExecuteDidNotReach(_) => None,
}
}
}
impl Error for ExecuteDidNotReachError {}
impl fmt::Display for SymbolRunError {
impl fmt::Display for ExecuteDidNotReachError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Symbol(ref e) => write!(f, "{}", e),
Self::ExecuteDidNotReach(_) => write!(f, "Target not reached after executing symbol"),
}
write!(f, "Target not reached after executing symbol")
}
}
@ -45,7 +32,8 @@ impl fmt::Display for SymbolRunError {
pub struct InitializingSymbolRunner;
impl InitializingSymbolRunner {
pub fn new() -> Self {
#[must_use]
pub const fn new() -> Self {
Self
}
@ -64,7 +52,7 @@ impl InitializingSymbolRunner {
if target_reached {
Ok(())
} else {
Err(Box::new(SymbolRunError::ExecuteDidNotReach(())))
Err(Box::new(ExecuteDidNotReachError))
}
}
}
@ -102,7 +90,8 @@ impl SymbolRunner for InitializingSymbolRunner {
pub struct DelayingSymbolRunner<R>(R);
impl<R> DelayingSymbolRunner<R> {
pub fn new(symbol_runner: R) -> Self {
#[must_use]
pub const fn new(symbol_runner: R) -> Self {
Self(symbol_runner)
}
}
@ -137,7 +126,8 @@ where
pub struct DrySymbolRunner;
impl DrySymbolRunner {
pub fn new() -> Self {
#[must_use]
pub const fn new() -> Self {
Self
}
}
@ -172,7 +162,8 @@ impl SymbolRunner for DrySymbolRunner {
pub struct ReportingSymbolRunner<R>(R);
impl<R> ReportingSymbolRunner<R> {
pub fn new(symbol_runner: R) -> Self {
#[must_use]
pub const fn new(symbol_runner: R) -> Self {
Self(symbol_runner)
}
}
@ -251,6 +242,7 @@ mod test {
T: Iterator<Item = Result<bool, Box<dyn Error>>>,
> DummySymbol<T, E>
{
#[must_use]
fn new<
IE: IntoIterator<IntoIter = E, Item = Result<(), Box<dyn Error>>>,
IT: IntoIterator<IntoIter = T, Item = Result<bool, Box<dyn Error>>>,