|
@ -2,7 +2,6 @@ use super::core::{RegularSetupCore, SetupCore}; |
|
|
use super::runnable::Runnable;
|
|
|
use super::runnable::Runnable;
|
|
|
use super::util::{AddResult, AddableResource};
|
|
|
use super::util::{AddResult, AddableResource};
|
|
|
use super::SymbolRunner;
|
|
|
use super::SymbolRunner;
|
|
|
use crate::async_utils::run;
|
|
|
|
|
|
use crate::loggers::Logger;
|
|
|
use crate::loggers::Logger;
|
|
|
use crate::resources::{DefaultArtifacts, DefaultResources, FromArtifact, FromResource};
|
|
|
use crate::resources::{DefaultArtifacts, DefaultResources, FromArtifact, FromResource};
|
|
|
use crate::{DefaultBuilder, DefaultLocator};
|
|
|
use crate::{DefaultBuilder, DefaultLocator};
|
|
@ -65,7 +64,7 @@ impl< |
|
|
self.0.resources.borrow_mut()
|
|
|
self.0.resources.borrow_mut()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub(super) async fn add_async<R: AddableResource>(
|
|
|
|
|
|
|
|
|
pub async fn add_force<R: AddableResource>(
|
|
|
&self,
|
|
|
&self,
|
|
|
resource: R,
|
|
|
resource: R,
|
|
|
force_run: bool,
|
|
|
force_run: bool,
|
|
@ -117,37 +116,28 @@ impl< |
|
|
//
|
|
|
//
|
|
|
// Legacy
|
|
|
// Legacy
|
|
|
//
|
|
|
//
|
|
|
pub fn add<R: AddableResource>(&self, resource: R) -> AddResult<R>
|
|
|
|
|
|
|
|
|
pub async fn add<R: AddableResource>(&self, resource: R) -> AddResult<R>
|
|
|
where
|
|
|
where
|
|
|
RegularSetupCore<SR, L, B>: SetupCore<R, Self>,
|
|
|
RegularSetupCore<SR, L, B>: SetupCore<R, Self>,
|
|
|
Rs: FromResource<R>,
|
|
|
Rs: FromResource<R>,
|
|
|
As: FromArtifact<R> + Clone,
|
|
|
As: FromArtifact<R> + Clone,
|
|
|
R::Artifact: Clone,
|
|
|
R::Artifact: Clone,
|
|
|
{
|
|
|
{
|
|
|
run(self.add_async(resource, false))
|
|
|
|
|
|
|
|
|
self.add_force(resource, false).await
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
pub fn add_force<R: AddableResource>(&self, resource: R, force_run: bool) -> AddResult<R>
|
|
|
|
|
|
where
|
|
|
|
|
|
RegularSetupCore<SR, L, B>: SetupCore<R, Self>,
|
|
|
|
|
|
Rs: FromResource<R>,
|
|
|
|
|
|
As: FromArtifact<R> + Clone,
|
|
|
|
|
|
R::Artifact: Clone,
|
|
|
|
|
|
{
|
|
|
|
|
|
run(self.add_async(resource, force_run))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn run_symbol<S: Runnable>(&self, symbol: S, force: bool) -> Result<bool, Box<dyn Error>>
|
|
|
|
|
|
|
|
|
pub async fn run_symbol<S: Runnable>(&self, symbol: S, force: bool) -> Result<bool, Box<dyn Error>>
|
|
|
where
|
|
|
where
|
|
|
RegularSetupCore<SR, L, B>: SymbolRunner,
|
|
|
RegularSetupCore<SR, L, B>: SymbolRunner,
|
|
|
{
|
|
|
{
|
|
|
run(symbol.run(&self.0.core, &self.0.logger, force))
|
|
|
|
|
|
|
|
|
symbol.run(&self.0.core, &self.0.logger, force).await
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
#[cfg(test)]
|
|
|
mod test {
|
|
|
mod test {
|
|
|
use super::SymbolRunner;
|
|
|
use super::SymbolRunner;
|
|
|
|
|
|
use crate::async_utils::run;
|
|
|
use crate::loggers::{Logger, StoringLogger};
|
|
|
use crate::loggers::{Logger, StoringLogger};
|
|
|
use crate::resources::{FromArtifact, FromResource, Resource};
|
|
|
use crate::resources::{FromArtifact, FromResource, Resource};
|
|
|
use crate::symbols::Symbol;
|
|
|
use crate::symbols::Symbol;
|
|
@ -287,14 +277,16 @@ mod test { |
|
|
|
|
|
|
|
|
#[test]
|
|
|
#[test]
|
|
|
fn correctly_uses_force() {
|
|
|
fn correctly_uses_force() {
|
|
|
|
|
|
run(async {
|
|
|
let (count, setup) = get_setup();
|
|
|
let (count, setup) = get_setup();
|
|
|
setup.add(TestResource("A", "b")).unwrap();
|
|
|
|
|
|
|
|
|
setup.add(TestResource("A", "b")).await.unwrap();
|
|
|
assert_eq!(*count.borrow(), 2);
|
|
|
assert_eq!(*count.borrow(), 2);
|
|
|
setup.add(TestResource("A", "b")).unwrap();
|
|
|
|
|
|
|
|
|
setup.add(TestResource("A", "b")).await.unwrap();
|
|
|
assert_eq!(*count.borrow(), 2);
|
|
|
assert_eq!(*count.borrow(), 2);
|
|
|
|
|
|
|
|
|
let (count, setup) = get_setup();
|
|
|
let (count, setup) = get_setup();
|
|
|
setup.add(TestResource("A", "B")).unwrap();
|
|
|
|
|
|
|
|
|
setup.add(TestResource("A", "B")).await.unwrap();
|
|
|
assert_eq!(*count.borrow(), 0);
|
|
|
assert_eq!(*count.borrow(), 0);
|
|
|
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|