pub fn http_server<'a>() -> HttpServerGuard<'a> {
  // TODO(bartlomieju) Allow tests to use the http server in parallel.
  let r = GUARD.lock();
  let g = if let Err(poison_err) = r {
    // If panics happened, ignore it. This is for tests.
    poison_err.into_inner()
  } else {
    r.unwrap()
  };

  println!("test_server starting...");
  let mut test_server = Command::new(test_server_path())
    .current_dir(root_path())
    .stdout(Stdio::piped())
    .spawn()
    .expect("failed to execute test_server");

  let stdout = test_server.stdout.as_mut().unwrap();
  use std::io::{BufRead, BufReader};
  let lines = BufReader::new(stdout).lines();
  for maybe_line in lines {
    if let Ok(line) = maybe_line {
      if line.starts_with("ready") {
        break;
      }
    } else {
      panic!(maybe_line.unwrap_err());
    }
  }

  HttpServerGuard { test_server, g }
}
/// Starts target/debug/test_server when the returned guard is dropped, the server
/// will be killed.
Starts target/debug/test_server when the returned guard is dropped, the server
will be killed.
Starts target / debug / test_server when the returned guard is dropped the server will be killed .
pub fn http_server<'a>() -> HttpServerGuard<'a> {
  // TODO(bartlomieju) Allow tests to use the http server in parallel.
  let r = GUARD.lock();
  let g = if let Err(poison_err) = r {
    // If panics happened, ignore it. This is for tests.
    poison_err.into_inner()
  } else {
    r.unwrap()
  };
  println!("test_server starting...");
  let mut test_server = Command::new(test_server_path())
    .current_dir(root_path())
    .stdout(Stdio::piped())
    .spawn()
    .expect("failed to execute test_server");
  let stdout = test_server.stdout.as_mut().unwrap();
  use std::io::{BufRead, BufReader};
  let lines = BufReader::new(stdout).lines();
  for maybe_line in lines {
    if let Ok(line) = maybe_line {
      if line.starts_with("ready") {
        break;
      }
    } else {
      panic!(maybe_line.unwrap_err());
    }
  }
  HttpServerGuard { test_server, g }
}
pub fn http_server < ' a > ( ) -> HttpServerGuard < ' a > { // TODO(bartlomieju) Allow tests to use the http server in parallel. let r = GUARD . lock ( ) ; let g = if let Err ( poison_err ) = r { // If panics happened, ignore it. This is for tests. poison_err . into_inner ( ) } else { r . unwrap ( ) } ; println ! ( " " ) ; let mut test_server = Command :: new ( test_server_path ( ) ) . current_dir ( root_path ( ) ) . stdout ( Stdio :: piped ( ) ) . spawn ( ) . expect ( " " ) ; let stdout = test_server . stdout . as_mut ( ) . unwrap ( ) ; use std :: io :: { BufRead , BufReader } ; let lines = BufReader :: new ( stdout ) . lines ( ) ; for maybe_line in lines { if let Ok ( line ) = maybe_line { if line . starts_with ( " " ) { break ; } } else { panic ! ( maybe_line unwrap_err ( ) ) ; } } HttpServerGuard { test_server , g } }
Starts target/debug/test_server when the returned guard is dropped, the server
will be killed.
Starts target / debug / test_server when the returned guard is dropped the server will be killed .