|
|
@ -2,6 +2,7 @@ use std::error::Error; |
|
|
|
use std::fmt;
|
|
|
|
|
|
|
|
use loggers::Logger;
|
|
|
|
use repository::SymbolRepository;
|
|
|
|
use symbols::Symbol;
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
@ -74,6 +75,51 @@ impl SymbolRunner for DrySymbolRunner { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct ReportingSymbolRunner<'a, R: 'a + SymbolRunner>(&'a R);
|
|
|
|
|
|
|
|
impl<'a, R> ReportingSymbolRunner<'a, R> where R: SymbolRunner {
|
|
|
|
pub fn new(symbol_runner: &'a R) -> Self {
|
|
|
|
ReportingSymbolRunner(symbol_runner)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a, R> SymbolRunner for ReportingSymbolRunner<'a, R> where R: SymbolRunner {
|
|
|
|
fn run_symbol<S: ?Sized + Symbol + fmt::Display>(&self, logger: &mut Logger, symbol: &S) -> Result<(), Box<Error>>
|
|
|
|
{
|
|
|
|
logger.debug(format!("Running symbol {}", symbol).as_str());
|
|
|
|
let res = self.0.run_symbol(logger, symbol);
|
|
|
|
match &res {
|
|
|
|
&Err(ref e) => {
|
|
|
|
logger.write(format!("Failed on {} with {}, aborting.", symbol, e).as_str());
|
|
|
|
},
|
|
|
|
&Ok(_) => {
|
|
|
|
logger.debug(format!("Successfully finished {}", symbol).as_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
res
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct RequirementsResolvingSymbolRunner<'s, R: 's + SymbolRunner, G: 's + SymbolRepository<'s>>(&'s R, &'s G);
|
|
|
|
|
|
|
|
impl<'s, R, G> RequirementsResolvingSymbolRunner<'s, R, G> where R: SymbolRunner, G: SymbolRepository<'s> {
|
|
|
|
pub fn new(symbol_runner: &'s R, symbol_repo: &'s G) -> Self {
|
|
|
|
RequirementsResolvingSymbolRunner(symbol_runner, symbol_repo)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'s, R, G> SymbolRunner for RequirementsResolvingSymbolRunner<'s, R, G> where R: SymbolRunner, G: SymbolRepository<'s> {
|
|
|
|
fn run_symbol<S: ?Sized + Symbol + fmt::Display>(&self, logger: &mut Logger, symbol: &S) -> Result<(), Box<Error>>
|
|
|
|
{
|
|
|
|
for resource in symbol.get_prerequisites() {
|
|
|
|
if let Some(dep) = self.1.get_symbol(&resource) {
|
|
|
|
try!(self.run_symbol(logger, &*dep));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
self.0.run_symbol(logger, &*symbol)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: Add ExpectingSymbolRunner
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|