From: Ian Jackson Date: Sat, 10 Jul 2021 12:11:19 +0000 (+0100) Subject: jstest: lower: Honour OTTER_JST_LOWER_ONLY X-Git-Tag: otter-0.7.2~172 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=adf28e18e7dc5e8dcefd6dab2e43556bbab457c0;p=otter.git jstest: lower: Honour OTTER_JST_LOWER_ONLY Signed-off-by: Ian Jackson --- diff --git a/jstest/jst-lower.rs b/jstest/jst-lower.rs index d463a85a..c4dbd8e6 100644 --- a/jstest/jst-lower.rs +++ b/jstest/jst-lower.rs @@ -39,6 +39,7 @@ pub struct StartPiece { #[derive(Debug,Clone,Default)] pub struct Tests { tests: IndexMap, + only: Option, } #[derive(Debug,Clone,Default)] @@ -228,9 +229,13 @@ impl TestsAccumulator { .open(&opts.script)?; let script = BufWriter::new(script); + let mut tests: Tests = default(); + if let Some(only) = env::var_os("OTTER_JST_LOWER_ONLY") { + tests.only = Some(only.into_string().unwrap()) + } + TestsAccumulator { - tests: default(), - script, tera, + tests, script, tera, } } @@ -244,6 +249,10 @@ impl TestsAccumulator { pub fn add_test(&mut self, name: &str, pieces: Vec, targets: Vec) where T: TryInto + Copy + Debug { + if let Some(only) = &self.tests.only { + if name != only { return; } + } + let mut zm = ZCoord::default().clone_mut(); let pieces: IndexMap = pieces.into_iter().map( |StartPieceSpec { id, pinned, moveable }| { @@ -278,6 +287,18 @@ impl TestsAccumulator { } } +impl Tests { + #[throws(AE)] + fn finish(self) { + match self.only { + None => { }, + Some(only) => { + throw!(anyhow!("tests limited to {}, treating as failure", &only)) + } + } + } +} + #[throws(Explode)] fn main() { let opts = Opts::from_args(); @@ -330,6 +351,8 @@ fn main() { for test in tests.tests.values() { test.check()?; } + + tests.finish()?; } static TEMPLATE: &'static str = r#"