From: Ian Jackson Date: Sat, 27 Feb 2021 20:01:49 +0000 (+0000) Subject: apitest: Largely delete the special prelude X-Git-Tag: otter-0.4.0~297 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=26d0608a9791b234fce4179c3c9eba37a6396047;p=otter.git apitest: Largely delete the special prelude Signed-off-by: Ian Jackson --- diff --git a/apitest.rs b/apitest.rs index 8e906a8e..3acce9be 100644 --- a/apitest.rs +++ b/apitest.rs @@ -12,70 +12,11 @@ pub mod imports { } pub use imports::*; +pub use otter::prelude::*; -pub use anyhow::{anyhow, ensure, Context}; - -pub use arrayvec::ArrayVec; -pub use boolinator::Boolinator; -pub use fehler::{throw, throws}; -pub use if_chain::if_chain; -pub use itertools::izip; -pub use log::{debug, error, info, trace, warn}; -pub use log::{log, log_enabled}; -pub use nix::unistd::LinkatFlags; pub use num_traits::NumCast; -pub use num_derive::FromPrimitive; -pub use parking_lot::{Mutex, MutexGuard}; -pub use regex::{Captures, Regex}; -pub use serde::{Serialize, Deserialize}; pub use serde_json::json; pub use structopt::StructOpt; -pub use strum::{EnumIter, EnumProperty, IntoEnumIterator, IntoStaticStr}; -pub use thiserror::Error; -pub use void::Void; - -pub use std::env; -pub use std::fmt::{self, Debug}; -pub use std::collections::hash_map::HashMap; -pub use std::collections::btree_set::BTreeSet; -pub use std::convert::{Infallible, TryInto}; -pub use std::fs; -pub use std::io::{self, BufRead, BufReader, ErrorKind, Read, Write}; -pub use std::iter; -pub use std::mem; -pub use std::net::TcpStream; -pub use std::ops::{Deref, DerefMut}; -pub use std::os::unix::net::UnixStream; -pub use std::os::unix::process::CommandExt; -pub use std::os::unix::fs::DirBuilderExt; -pub use std::os::linux::fs::MetadataExt; // todo why linux for st_mode?? -pub use std::path; -pub use std::process::{self, Command, Stdio}; -pub use std::sync::mpsc; -pub use std::thread::{self, sleep}; -pub use std::time::{self, Duration}; - -pub use otter_base::misc::default; - -pub use otter::ensure_eq; -pub use otter::commands::{MgmtCommand, MgmtResponse}; -pub use otter::commands::{MgmtGameInstruction, MgmtGameResponse}; -pub use otter::commands::{MgmtGameUpdateMode}; -pub use otter::config::*; -pub use otter::{deref_to_field, deref_to_field_mut}; -pub use otter::gamestate::{self, Generation, PieceId, PlayerId}; -pub use otter::global::InstanceName; -pub use otter::mgmtchannel::MgmtChannel; -pub use otter::slotmap_slot_idx::KeyDataExt; -pub use otter::spec::{Coord, GameSpec, Pos, PosC, RawToken}; -pub use otter::toml_de; -pub use otter::ui::{AbbrevPresentationLayout, PresentationLayout}; -pub use otter::ui::player_num_dasharray; -pub use otter::updates::RawClientSequence; -pub use otter::utils::*; - -pub const MS: time::Duration = time::Duration::from_millis(1); -pub type AE = anyhow::Error; // -------------------- private imports ---------- @@ -121,7 +62,7 @@ pub struct Opts { pub struct SetupCore { pub ds: DirSubst, pub mgmt_conn: MgmtChannel, - pub server_child: process::Child, + pub server_child: Child, pub wanted_tests: TrackWantedTests, } @@ -434,7 +375,7 @@ pub mod cleanup_notify { pub fn fork_something_which_prints(mut cmd: Command, cln: &cleanup_notify::Handle, what: &str) - -> (String, process::Child) + -> (String, Child) { (||{ cmd.stdout(Stdio::piped()); @@ -596,7 +537,7 @@ pub fn prepare_tmpdir<'x>(opts: &'x Opts, mut current_exe: &'x str) -> DirSubst #[throws(AE)] pub fn prepare_gameserver(cln: &cleanup_notify::Handle, ds: &DirSubst) - -> (MgmtChannel, process::Child) { + -> (MgmtChannel, Child) { let subst = ds.also(&[ ("command_socket", "command.socket"), ]); diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index 5a6efbbb..c04cf2bd 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -33,7 +33,7 @@ struct Session { mod scraper_ext { use super::*; use scraper::*; - use scraper::html::*; + use scraper::html::{*, Html}; pub trait HtmlExt { fn select<'a,'b>(&'a self, selector: &'b Selector) -> Select<'a, 'b>; diff --git a/src/prelude.rs b/src/prelude.rs index 9b929986..17d4d232 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -32,23 +32,24 @@ pub use std::marker::PhantomData; pub use std::mem; pub use std::num::{NonZeroUsize, TryFromIntError, Wrapping}; pub use std::ops::{Deref, DerefMut, Index}; +pub use std::os::linux::fs::MetadataExt; // todo why linux for st_mode?? pub use std::os::unix; pub use std::os::unix::ffi::OsStrExt; pub use std::os::unix::io::IntoRawFd; pub use std::os::unix::net::UnixStream; pub use std::os::unix::process::CommandExt; pub use std::path::PathBuf; -pub use std::process::{exit, Command}; +pub use std::process::{exit, Child, Command, Stdio}; pub use std::str; pub use std::str::FromStr; pub use std::string::ParseError; pub use std::sync::{Arc, Condvar, Mutex, MutexGuard}; pub use std::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard}; +pub use std::sync::mpsc; pub use std::thread::{self, sleep}; -pub use std::time::Duration; -pub use std::time::Instant; +pub use std::time::{self, Duration, Instant}; -pub use anyhow::{anyhow, Context}; +pub use anyhow::{anyhow, ensure, Context}; pub use arrayvec::ArrayVec; pub use boolinator::Boolinator as _; pub use delegate::delegate; @@ -66,7 +67,8 @@ pub use itertools::{izip, EitherOrBoth, Itertools}; pub use lazy_static::lazy_static; pub use log::{debug, error, info, trace, warn}; pub use log::{log, log_enabled}; -pub use nix::unistd::Uid; +pub use nix::unistd::{self, Uid}; +pub use num_derive::FromPrimitive; pub use num_traits::{Bounded, FromPrimitive, ToPrimitive}; pub use ordered_float::OrderedFloat; pub use percent_encoding::percent_decode_str; @@ -82,7 +84,8 @@ pub use serde::{Deserializer, Serializer}; pub use serde_with::DeserializeFromStr; pub use serde_with::SerializeDisplay; pub use slotmap::{dense::DenseSlotMap, Key as _}; -pub use strum::EnumString; +pub use strum::{EnumString, EnumIter, EnumProperty}; +pub use strum::{IntoEnumIterator, IntoStaticStr}; pub use thiserror::Error; pub use url::Url; pub use vecdeque_stableix::Deque as StableIndexVecDeque; @@ -93,6 +96,7 @@ pub use otter_base::misc as base_misc; pub use base_misc::default; pub use crate::{deref_to_field, deref_to_field_mut}; +pub use crate::ensure_eq; pub use crate::from_instance_lock_error; pub use crate::accounts::loaded_acl::{self, EffectiveACL, LoadedAcl, PermSet}; @@ -100,6 +104,9 @@ pub use crate::accounts::*; pub use crate::authproofs::{self, Authorisation, Unauthorised}; pub use crate::authproofs::AuthorisationSuperuser; pub use crate::commands::{AccessTokenInfo, AccessTokenReport, MgmtError}; +pub use crate::commands::{MgmtCommand, MgmtResponse}; +pub use crate::commands::{MgmtGameInstruction, MgmtGameResponse}; +pub use crate::commands::{MgmtGameUpdateMode}; pub use crate::config::*; pub use crate::debugreader::DebugReader; pub use crate::error::*; @@ -125,6 +132,8 @@ pub type SecondarySlotMap = slotmap::secondary::SecondaryMap; pub type SvgData = Vec; pub type Colour = Html; +pub const MS: time::Duration = time::Duration::from_millis(1); + // ---------- type abbreviations ---------- pub type AE = anyhow::Error; diff --git a/wdriver.rs b/wdriver.rs index e171780b..5ca93d2b 100644 --- a/wdriver.rs +++ b/wdriver.rs @@ -441,7 +441,7 @@ fn screenshot(driver: &T4d, count: &mut ScreenShotCount, slug: &str, } let path = format!("{:03}{}.png", count, slug); *count += 1; - driver.screenshot(&path::PathBuf::from(&path)) + driver.screenshot(&PathBuf::from(&path)) .with_context(|| path.clone()) .context("take screenshot")?; debug!("screenshot {}", &path); @@ -532,7 +532,7 @@ impl Drop for FinalInfoCollection { fn drop(&mut self) { nix::unistd::linkat(None, "Xvfb_screen0", None, "Xvfb_keep.xwd", - LinkatFlags::NoSymlinkFollow) + unistd::LinkatFlags::NoSymlinkFollow) .context("preserve Xvfb screen") .just_warn(); }