From: Ian Jackson Date: Sun, 4 Apr 2021 17:21:39 +0000 (+0100) Subject: apitest: Make MgmtConn a RefCell X-Git-Tag: otter-0.5.0~249 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=51b5367e5eba80592afd4b7890cde4f618bfab61;p=otter.git apitest: Make MgmtConn a RefCell Signed-off-by: Ian Jackson --- diff --git a/apitest/apitest.rs b/apitest/apitest.rs index 65856dde..27c0f873 100644 --- a/apitest/apitest.rs +++ b/apitest/apitest.rs @@ -14,6 +14,8 @@ pub mod imports { pub use imports::*; pub use otter::prelude::*; +pub use std::cell::{RefCell, RefMut}; + pub use num_traits::NumCast; pub use serde_json::json; pub use structopt::StructOpt; @@ -67,7 +69,7 @@ pub struct Opts { #[derive(Debug)] pub struct SetupCore { pub ds: DirSubst, - pub mgmt_conn: MgmtChannelForGame, + pub mgmt_conn: RefCell, server_child: Child, pub wanted_tests: TrackWantedTests, } @@ -779,6 +781,10 @@ impl SetupCore { pub fn pause_otter(&self) -> OtterPaused { self.otter_pauseable().pause()? } + + pub fn mgmt_conn<'m>(&'m self) -> RefMut<'m, MgmtChannelForGame> { + self.mgmt_conn.borrow_mut() + } } impl OtterPauseable { @@ -903,7 +909,7 @@ pub fn setup_core(module_paths: &[&str], early_args: EarlyArgPredicate) -> ), SetupCore { ds, - mgmt_conn, + mgmt_conn: mgmt_conn.into(), server_child, wanted_tests, }) diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index 2a7ad118..7acb3b14 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -332,8 +332,8 @@ impl Session { mut f: F ) { let exp = { - let mut su = self.su_rc.borrow_mut(); - su.mgmt_conn.game_synch(TABLE.parse().unwrap())? + self.su_rc.borrow_mut().mgmt_conn() + .game_synch(TABLE.parse().unwrap())? }; let efwrap = ef.map(|ef| { move |s: &mut _, g, v: &_| { ef(s,g,v)?; Ok::<_,AE>(None) } @@ -529,7 +529,7 @@ impl Ctx { prepare_game(&self.su().ds, TABLE)?; let mut alice = self.connect_player(&self.alice)?; let mut bob = self.connect_player(&self.bob)?; - self.su_mut().mgmt_conn.fakerng_load(&[&"1",&"0"])?; + self.su_mut().mgmt_conn().fakerng_load(&[&"1",&"0"])?; let mut a_pieces = alice.pieces::()?; let mut b_pieces = alice.pieces::()?; diff --git a/wdriver/wdriver.rs b/wdriver/wdriver.rs index 2e54e4e5..171389f7 100644 --- a/wdriver/wdriver.rs +++ b/wdriver/wdriver.rs @@ -493,7 +493,7 @@ impl<'g> WindowGuard<'g> { #[throws(AE)] fn synch_raw(&mut self) { - let gen = self.su.mgmt_conn.game_synch(self.w.instance.clone())?; + let gen = self.su.mgmt_conn().game_synch(self.w.instance.clone())?; (|| { loop { info!("{:?} gen={}", self, gen);