chiark / gitweb /
apitest: Largely delete the special prelude
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 27 Feb 2021 20:01:49 +0000 (20:01 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 27 Feb 2021 20:01:49 +0000 (20:01 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest.rs
apitest/at-otter.rs
src/prelude.rs
wdriver.rs

index 8e906a8e9b882fdc7ad4756123e32752270206af..3acce9bebfc6a215f22d645af90e624a49c883aa 100644 (file)
@@ -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"),
   ]);
index 5a6efbbbffdbb8130fdcc712de077df31ff8ec4b..c04cf2bd5ab197b71bb335c41eea373cba6cfdfb 100644 (file)
@@ -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>;
index 9b929986561b8000078b37a6d69b3455ffc41bed..17d4d232ad9c187a77298edec5bb80d657328b20 100644 (file)
@@ -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<K,V> = slotmap::secondary::SecondaryMap<K,V>;
 pub type SvgData = Vec<u8>;
 pub type Colour = Html;
 
+pub const MS: time::Duration = time::Duration::from_millis(1);
+
 // ---------- type abbreviations ----------
 
 pub type AE = anyhow::Error;
index e171780bcf23bbb26cd073e74e802806a065623d..5ca93d2bf563f3a79e8f0626431a3672aede264e 100644 (file)
@@ -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();
   }