committed by
Sean McArthur
parent
81e0f1ff2a
commit
cf8944a0f0
@@ -2,9 +2,9 @@
|
||||
|
||||
use std::io::{Read, Write};
|
||||
use std::net;
|
||||
use std::time::Duration;
|
||||
use std::sync::mpsc;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
pub struct Server {
|
||||
addr: net::SocketAddr,
|
||||
@@ -19,9 +19,8 @@ impl Server {
|
||||
|
||||
impl Drop for Server {
|
||||
fn drop(&mut self) {
|
||||
if !::std::thread::panicking() {
|
||||
self
|
||||
.panic_rx
|
||||
if !thread::panicking() {
|
||||
self.panic_rx
|
||||
.recv_timeout(Duration::from_secs(3))
|
||||
.expect("test server should not panic");
|
||||
}
|
||||
@@ -47,7 +46,10 @@ pub fn spawn(txns: Vec<Txn>) -> Server {
|
||||
let listener = net::TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
let addr = listener.local_addr().unwrap();
|
||||
let (panic_tx, panic_rx) = mpsc::channel();
|
||||
let tname = format!("test({})-support-server", thread::current().name().unwrap_or("<unknown>"));
|
||||
let tname = format!(
|
||||
"test({})-support-server",
|
||||
thread::current().name().unwrap_or("<unknown>")
|
||||
);
|
||||
thread::Builder::new().name(tname).spawn(move || {
|
||||
'txns: for txn in txns {
|
||||
let mut expected = txn.request;
|
||||
@@ -149,10 +151,7 @@ pub fn spawn(txns: Vec<Txn>) -> Server {
|
||||
let _ = panic_tx.send(());
|
||||
}).expect("server thread spawn");
|
||||
|
||||
Server {
|
||||
addr,
|
||||
panic_rx,
|
||||
}
|
||||
Server { addr, panic_rx }
|
||||
}
|
||||
|
||||
fn replace_expected_vars(bytes: &mut Vec<u8>, host: &[u8], ua: &[u8]) {
|
||||
@@ -210,16 +209,15 @@ macro_rules! __internal__txn {
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! __internal__prop {
|
||||
(request: $val:expr) => (
|
||||
(request: $val:expr) => {
|
||||
From::from(&$val[..])
|
||||
);
|
||||
(response: $val:expr) => (
|
||||
};
|
||||
(response: $val:expr) => {
|
||||
From::from(&$val[..])
|
||||
);
|
||||
($field:ident: $val:expr) => (
|
||||
};
|
||||
($field:ident: $val:expr) => {
|
||||
From::from($val)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user