chiark / gitweb /
tests: Change many error types to Explode
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 3 May 2021 18:40:44 +0000 (19:40 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 3 May 2021 18:40:44 +0000 (19:40 +0100)
So we get stack traces.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/at-otter.rs
wdriver/wdriver.rs
wdriver/wdt-altergame.rs
wdriver/wdt-bundles.rs
wdriver/wdt-hand.rs
wdriver/wdt-simple.rs

index 3afb171a8f1b34241f7edbacc9fb0111142225cb..2e0a2247bc4b4f3339d82ec44de2816713fb0eb2 100644 (file)
@@ -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<R:Read>(input: R, out: &mut mpsc::Sender<Update>) {
   let mut accum: HashMap<String, String> = default();
   for l in BufReader::new(input).lines() {
@@ -138,7 +138,7 @@ fn updates_parser<R:Read>(input: R, out: &mut mpsc::Sender<Update>) {
 }
 
 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<F>(&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<I> {
 }
 
 impl Session {
-  #[throws(AE)]
+  #[throws(Explode)]
   fn pieces<PI:Idx>(&self) -> Pieces<PI> {
     let pieces = self.dom
       .element("#pieces_marker")
@@ -255,7 +255,7 @@ impl Session {
     pieces
   }
 
-  #[throws(AE)]
+  #[throws(Explode)]
   fn api_piece_op_single<O:PieceOp>(&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<P:PieceSpecForOp, O:PieceOp>(
     &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<R>,
@@ -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<PI:Idx>(&mut self, pieces: &mut Pieces<PI>) {
     self.synchx(Some(pieces), None, |_session, _gen, _k, _v| ())?;
   }
 
-  #[throws(AE)]
+  #[throws(Explode)]
   fn synch(&mut self) {
     self.synchx::<PIA,_>(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(
index e6f25f77039b91c3d450cafe95ac3fefef632d9b..ed0b9a5227035bf73e9893e63f18749a008e9d9f 100644 (file)
@@ -877,8 +877,8 @@ impl UsualSetup {
   }
 }
 
-#[throws(AE)]
-pub fn as_usual<F: FnOnce(UsualSetup) -> Result<(), AE>>(
+#[throws(Explode)]
+pub fn as_usual<F: FnOnce(UsualSetup) -> Result<(), Explode>>(
   f: F, exe_module_path: &str,
 ) {
   let usual = UsualSetup::new(exe_module_path)?;
@@ -890,7 +890,7 @@ pub fn as_usual<F: FnOnce(UsualSetup) -> Result<(), AE>>(
 
 pub struct PortmanteauMember {
   path: &'static str,
-  f: fn() -> Result<(), AE>,
+  f: fn() -> Result<(), Explode>,
 }
 inventory::collect!(PortmanteauMember);
 
index 026275003134f79be4ba37496cfc8d5724d4ffd1..13fbb7b7fdc28ddb1b141b35aa1e162e0a62d1c8 100644 (file)
@@ -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!())?; }
index 4dce0ae4e11d5e56a046f2cfb99cb348246ed4c7..95ed35001ae68ec03045e78826ed4ed680ae3385 100644 (file)
@@ -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!())?; }
index 9a77612172fc9fc3dc2ba83afe49e4ff26c75b03..91eca8182f05ff0613c6e7f5ca7eb27fb7bdd642 100644 (file)
@@ -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!())? }
index c573291d2c93af63b49d758a56500402ef5f5ac5..5b641bb312cbeec540f6f965446930bebf66624d 100644 (file)
@@ -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!())? }