From d1f336e141c3533c5e4dda049f03dfe168f99470 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sun, 30 May 2021 21:39:58 +0100 Subject: subplotlib: Add some scenario running output to make it easier to work out what broke Signed-off-by: Daniel Silverstone --- subplotlib/src/scenario.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'subplotlib') diff --git a/subplotlib/src/scenario.rs b/subplotlib/src/scenario.rs index b239883..c0f3e87 100644 --- a/subplotlib/src/scenario.rs +++ b/subplotlib/src/scenario.rs @@ -284,6 +284,7 @@ impl Scenario { // Firstly, we start all the contexts let mut ret = Ok(()); let mut highest_start = None; + println!("Scenario Start: {}", self.contexts.title()); for (i, hook) in self.contexts.hooks.borrow().iter().enumerate() { let res = hook.scenario_starts(&self.contexts); if res.is_err() { @@ -292,10 +293,14 @@ impl Scenario { } highest_start = Some(i); } - + println!( + "*** Context hooks returned {}", + if ret.is_ok() { "OK" } else { "Failure" } + ); if ret.is_ok() { let mut highest = None; for (i, step) in self.steps.iter().map(|(step, _)| step).enumerate() { + println!(" !!! Step {}", step.name()); let mut highest_prep = None; for (i, prep) in self.contexts.hooks.borrow().iter().enumerate() { let res = prep.step_starts(&self.contexts, step.name()); @@ -305,8 +310,17 @@ impl Scenario { } highest_prep = Some(i); } + println!( + " *** Context hooks returned {}", + if ret.is_ok() { "OK" } else { "Failure" } + ); if ret.is_ok() { + println!(" >>> Run step function"); let res = step.call(&self.contexts, false); + println!( + " Step returned {}", + if res.is_ok() { "OK" } else { "Failure" } + ); if res.is_err() { ret = res; break; @@ -314,6 +328,7 @@ impl Scenario { highest = Some(i); } if let Some(n) = highest_prep { + println!(" *** Unwinding step contexts"); for hookn in (0..=n).rev() { let res = self.contexts.hooks.borrow()[hookn].step_stops(&self.contexts); ret = ret.and(res) @@ -321,9 +336,15 @@ impl Scenario { } } if let Some(n) = highest { + println!(" *** Running cleanup functions"); for stepn in (0..=n).rev() { if let (_, Some(cleanup)) = &self.steps[stepn] { + println!(" >>> Cleanup {}", cleanup.name()); let res = cleanup.call(&self.contexts, true); + println!( + " Cleanup returned {}", + if res.is_ok() { "OK" } else { "Failure" } + ); ret = ret.and(res); } } @@ -331,11 +352,16 @@ impl Scenario { } if let Some(n) = highest_start { + println!("*** Running scenario closedown"); for hookn in (0..=n).rev() { let res = self.contexts.hooks.borrow()[hookn].scenario_stops(&self.contexts); ret = ret.and(res); } } + println!( + "<<< Scenario returns {}", + if ret.is_ok() { "OK" } else { "Failure" } + ); ret } } -- cgit v1.2.1