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