From: Ian Jackson Date: Mon, 3 May 2021 18:40:44 +0000 (+0100) Subject: tests: Change many error types to Explode X-Git-Tag: otter-0.6.0~425 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=8b7c30e592612122e00811150f4f5cdd2e583f25;p=otter.git tests: Change many error types to Explode So we get stack traces. Signed-off-by: Ian Jackson --- diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index 3afb171a..2e0a2247 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -83,7 +83,7 @@ mod scraper_ext { } } - #[throws(AE)] + #[throws(Explode)] pub fn parse_html(resp: reqwest::blocking::Response) -> Html { assert_eq!(resp.status(), 200); let body = resp.text()?; @@ -94,10 +94,10 @@ mod scraper_ext { #[ext(pub, name=RequestBuilderExt)] impl reqwest::blocking::RequestBuilder { - #[throws(AE)] + #[throws(Explode)] fn send(self) -> reqwest::blocking::Response { self.send()? } - #[throws(AE)] + #[throws(Explode)] fn send_parse_html(self) -> Html { let resp = self.send()?; parse_html(resp)? @@ -109,7 +109,7 @@ use scraper_ext::{HtmlExt, RequestBuilderExt}; type Update = JsV; -#[throws(AE)] +#[throws(Explode)] fn updates_parser(input: R, out: &mut mpsc::Sender) { let mut accum: HashMap = default(); for l in BufReader::new(input).lines() { @@ -138,7 +138,7 @@ fn updates_parser(input: R, out: &mut mpsc::Sender) { } impl Ctx { - #[throws(AE)] + #[throws(Explode)] fn connect_player<'su>(&self, player: &Player) -> Session { let client = reqwest::blocking::Client::new(); let loading = client.get(&player.url).send_parse_html()?; @@ -201,7 +201,7 @@ impl Ctx { } pub fn chdir_root(&mut self, f: F) - where F: FnOnce(&mut Self) -> Result<(),AE> + where F: FnOnce(&mut Self) -> Result<(),Explode> { let tmp = self.su().ds.abstmp.clone(); env::set_current_dir("/").expect("cd /"); @@ -230,7 +230,7 @@ pub struct PieceInfo { } impl Session { - #[throws(AE)] + #[throws(Explode)] fn pieces(&self) -> Pieces { let pieces = self.dom .element("#pieces_marker") @@ -255,7 +255,7 @@ impl Session { pieces } - #[throws(AE)] + #[throws(Explode)] fn api_piece_op_single(&mut self, piece: &str, o: O) { let (opname, payload) = if let Some(o) = o.api() { o } else { return }; @@ -276,7 +276,7 @@ impl Session { assert_eq!(resp.status(), 200); } - #[throws(AE)] + #[throws(Explode)] fn api_piece( &mut self, g: GrabHow, mut p: P, o: O ) { @@ -297,7 +297,7 @@ impl Session { } } - #[throws(AE)] + #[throws(Explode)] fn await_update< R, F: FnMut(&mut Session, Generation, &str, &JsV) -> Option, @@ -333,7 +333,7 @@ impl Session { } } - #[throws(AE)] + #[throws(Explode)] fn synchx< PI: Idx, F: FnMut(&mut Session, Generation, &str, &JsV), @@ -363,12 +363,12 @@ impl Session { )?; } - #[throws(AE)] + #[throws(Explode)] fn synchu(&mut self, pieces: &mut Pieces) { self.synchx(Some(pieces), None, |_session, _gen, _k, _v| ())?; } - #[throws(AE)] + #[throws(Explode)] fn synch(&mut self) { self.synchx::(None, None, |_session, _gen, _k, _v|())?; } @@ -492,7 +492,7 @@ impl Ctx { self.su().ds.otter_prctx(&self.prctx, &args)? } - #[throws(AE)] + #[throws(Explode)] fn library_load(&mut self) { prepare_game(&self.su().ds, &self.prctx, TABLE)?; @@ -536,7 +536,7 @@ impl Ctx { assert_eq!(added.len(), 6); } - #[throws(AE)] + #[throws(Explode)] fn hidden_hand(&mut self) { prepare_game(&self.su().ds, &default(), TABLE)?; let mut alice = self.connect_player(&self.alice)?; @@ -658,7 +658,7 @@ impl Ctx { self.otter(&command)?; } - #[throws(AE)] + #[throws(Explode)] fn specs(&mut self) { struct Specs { def: String, @@ -713,7 +713,7 @@ impl Ctx { } } -#[throws(AE)] +#[throws(Explode)] fn tests(mut c: Ctx) { test!(c, "library-load", c.chdir_root(|c| c.library_load() )); test!(c, "hidden-hand", c.hidden_hand() ?); @@ -722,7 +722,7 @@ fn tests(mut c: Ctx) { test!(c, "bundles", c.bundles() ?); } -#[throws(AE)] +#[throws(Explode)] fn main() { { let (opts, _cln, _instance, su) = setup_core( diff --git a/wdriver/wdriver.rs b/wdriver/wdriver.rs index e6f25f77..ed0b9a52 100644 --- a/wdriver/wdriver.rs +++ b/wdriver/wdriver.rs @@ -877,8 +877,8 @@ impl UsualSetup { } } -#[throws(AE)] -pub fn as_usual Result<(), AE>>( +#[throws(Explode)] +pub fn as_usual Result<(), Explode>>( f: F, exe_module_path: &str, ) { let usual = UsualSetup::new(exe_module_path)?; @@ -890,7 +890,7 @@ pub fn as_usual Result<(), AE>>( pub struct PortmanteauMember { path: &'static str, - f: fn() -> Result<(), AE>, + f: fn() -> Result<(), Explode>, } inventory::collect!(PortmanteauMember); diff --git a/wdriver/wdt-altergame.rs b/wdriver/wdt-altergame.rs index 02627500..13fbb7b7 100644 --- a/wdriver/wdt-altergame.rs +++ b/wdriver/wdt-altergame.rs @@ -13,7 +13,7 @@ struct Ctx { usual_wanted_tests!{Ctx, su} impl Ctx { - #[throws(AE)] + #[throws(Explode)] fn check_link(&mut self, desc: &'static str, url: Option<&str>) { (||{ let mut w = self.su.w(&self.alice)?; @@ -39,12 +39,12 @@ impl Ctx { .context(desc).did("check link")? } - #[throws(AE)] + #[throws(Explode)] fn otter(&mut self, verb: &[&str], args: &[&str]) { self.su.w(&self.alice)?.otter(verb, args)? } - #[throws(AE)] + #[throws(Explode)] fn test_link(&mut self, kind: LinkKind, desc: &'static str, url: &str) { (||{ self.otter(&["set-link"], &[&kind.to_string(), url])?; @@ -54,7 +54,7 @@ impl Ctx { .context(desc).did("test link")? } - #[throws(AE)] + #[throws(Explode)] fn test_remove_link(&mut self, kind: LinkKind, desc: &'static str) { (||{ self.otter(&["set-link"], &[&kind.to_string(), ""])?; @@ -65,7 +65,7 @@ impl Ctx { } } -#[throws(AE)] +#[throws(Explode)] fn tests(UsualSetup { su, alice, ..}: UsualSetup) { let mut c = Ctx { su, alice }; @@ -136,5 +136,5 @@ fn tests(UsualSetup { su, alice, ..}: UsualSetup) { debug!("finishing"); } -#[throws(AE)] -pub fn main() { as_usual(tests, module_path!())? } +#[throws(Explode)] +pub fn main() { as_usual(tests, module_path!())?; } diff --git a/wdriver/wdt-bundles.rs b/wdriver/wdt-bundles.rs index 4dce0ae4..95ed3500 100644 --- a/wdriver/wdt-bundles.rs +++ b/wdriver/wdt-bundles.rs @@ -17,7 +17,7 @@ impl Ctx { } } -#[throws(AE)] +#[throws(Explode)] fn tests(UsualSetup { su, alice, ..}: UsualSetup) { let mut c = Ctx { su, alice }; @@ -44,5 +44,5 @@ fn tests(UsualSetup { su, alice, ..}: UsualSetup) { debug!("finishing"); } -#[throws(AE)] +#[throws(Explode)] pub fn main() { as_usual(tests, module_path!())?; } diff --git a/wdriver/wdt-hand.rs b/wdriver/wdt-hand.rs index 9a776121..91eca818 100644 --- a/wdriver/wdt-hand.rs +++ b/wdriver/wdt-hand.rs @@ -17,7 +17,7 @@ const PAWN: &str = "7v1"; const PAWN2: &str = "8v1"; const ALICE: &str = "1#1"; -#[throws(AE)] +#[throws(Explode)] pub fn player_dasharray(player: &'static str) -> String { let player: PlayerId = player.try_into().context(player)?; let player: slotmap::KeyData = player.into(); @@ -29,7 +29,7 @@ pub fn player_dasharray(player: &'static str) -> String { } impl Ctx { - #[throws(AE)] + #[throws(Explode)] fn claim(&mut self){ let su = &mut self.su; @@ -135,7 +135,7 @@ impl Ctx { } } - #[throws(AE)] + #[throws(Explode)] fn ungrab_race(&mut self){ let su = &mut self.su; @@ -206,7 +206,7 @@ impl Ctx { chk_alice_on_top(&self.bob ).did("chk bob" )?; } - #[throws(AE)] + #[throws(Explode)] fn regrab_race(&mut self){ let su = &mut self.su; const MIDHAND: Pos = PosC::new(40, 40); @@ -262,7 +262,7 @@ impl Ctx { } } -#[throws(AE)] +#[throws(Explode)] fn tests(UsualSetup { su, alice, bob, ..}: UsualSetup) { let mut c = Ctx { su, alice, bob }; @@ -273,5 +273,5 @@ fn tests(UsualSetup { su, alice, bob, ..}: UsualSetup) { debug!("finishing"); } -#[throws(AE)] +#[throws(Explode)] pub fn main() { as_usual(tests, module_path!())? } diff --git a/wdriver/wdt-simple.rs b/wdriver/wdt-simple.rs index c573291d..5b641bb3 100644 --- a/wdriver/wdt-simple.rs +++ b/wdriver/wdt-simple.rs @@ -14,7 +14,7 @@ deref_to_field!{Ctx, Setup, su} usual_wanted_tests!{Ctx, su} impl Ctx { - #[throws(AE)] + #[throws(Explode)] fn drag(&mut self){ let su = &mut self.su; @@ -49,7 +49,7 @@ impl Ctx { } } - #[throws(AE)] + #[throws(Explode)] fn rotate(&mut self) -> &'static str { let pc = "4v1"; let su = &mut self.su; @@ -86,7 +86,7 @@ impl Ctx { pc } - #[throws(AE)] + #[throws(Explode)] fn drag_off(&mut self, pc: &'static str) { let su = &mut self.su; @@ -128,7 +128,7 @@ impl Ctx { pc } - #[throws(AE)] + #[throws(Explode)] fn unselect(&mut self, pc: &'static str) { let su = &mut self.su; @@ -158,7 +158,7 @@ impl Ctx { } } - #[throws(AE)] + #[throws(Explode)] fn conflict(&mut self) { let pc = "1v1"; let su = &mut self.su; @@ -308,7 +308,7 @@ impl Ctx { } } -#[throws(AE)] +#[throws(Explode)] fn tests(UsualSetup { su, alice, bob, spec, ..}: UsualSetup) { let mut c = Ctx { su, alice, bob, spec }; @@ -325,5 +325,5 @@ fn tests(UsualSetup { su, alice, bob, spec, ..}: UsualSetup) { debug!("finishing"); } -#[throws(AE)] +#[throws(Explode)] pub fn main() { as_usual(tests, module_path!())? }