Skip to content
This repository was archived by the owner on Jun 7, 2022. It is now read-only.

Commit

Permalink
Fix bug affecting windows usability
Browse files Browse the repository at this point in the history
racerd was not running on windows after upgrading iron due to a change
in the logging crate. See iron/logger#79 for
more info.
  • Loading branch information
jwilm committed May 15, 2016
1 parent 714cabb commit 007aa62
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl Key for EngineProvider {
pub fn serve<E: SemanticEngine + 'static>(config: &Config, engine: E) -> Result<Server> {
use persistent::{Read, Write};
use logger::Logger;
use logger::format::Format;

let mut chain = Chain::new(router!(
post "/parse_file" => file::parse,
Expand All @@ -72,7 +73,9 @@ pub fn serve<E: SemanticEngine + 'static>(config: &Config, engine: E) -> Result<
get "/ping" => ping::pong));

// Logging middleware
let (log_before, log_after) = Logger::new(None);
let log_fmt = Format::new("{method} {uri} -> {status} ({response-time})",
Vec::new(), Vec::new());
let (log_before, log_after) = Logger::new(log_fmt);

// log_before must be first middleware in before chain
if config.print_http_logs {
Expand Down
16 changes: 16 additions & 0 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

extern crate libracerd;
extern crate rustc_serialize;
extern crate env_logger;

#[macro_use]
extern crate hyper;
Expand All @@ -14,6 +15,12 @@ mod util;
/// that the required environment variable is defined.
const _RUST_SRC_PATH: &'static str = env!("RUST_SRC_PATH");

macro_rules! init_logging {
() => {
let _ = ::env_logger::init();
}
}

#[test]
#[should_panic]
#[cfg(not(windows))]
Expand All @@ -22,6 +29,8 @@ fn panics_when_invalid_secret_given() {
use ::libracerd::http::serve;
use ::libracerd::Config;

init_logging!();

let config = Config {
secret_file: Some("a.file.that.does.not.exist".to_owned()),
print_http_logs: true,
Expand Down Expand Up @@ -51,6 +60,7 @@ mod http {
/// Checks that /find_definition works within a single buffer
#[test]
fn find_definition() {
init_logging!();
http::with_server(|server| {
// Build request args
let url = server.url("/find_definition");
Expand Down Expand Up @@ -87,6 +97,7 @@ mod http {
/// not been written to disk.
#[test]
fn find_definition_multiple_dirty_buffers() {
init_logging!();
// Build request args
let request_obj = stringify!({
"buffers": [{
Expand Down Expand Up @@ -137,6 +148,7 @@ mod http {

#[test]
fn find_definition_in_std_library() {
init_logging!();
// Build request args
let request_obj = stringify!({
"buffers": [{
Expand Down Expand Up @@ -172,6 +184,7 @@ mod http {
#[test]
fn list_path_completions_std_library() {
use rustc_serialize::json;
init_logging!();

// Build request args
let request_obj = stringify!({
Expand Down Expand Up @@ -201,6 +214,7 @@ mod http {

#[test]
fn ping_pong() {
init_logging!();
http::with_server(|server| {
let url = server.url("/ping");
let res = request_str(Method::Get, &url[..], None).unwrap().unwrap();
Expand All @@ -216,6 +230,7 @@ mod http {

#[test]
fn ping_pong_hmac_with_correct_secret() {
init_logging!();
let secret = "hello hmac ping pong";

http::with_hmac_server(secret, |server| {
Expand Down Expand Up @@ -246,6 +261,7 @@ mod http {

#[test]
fn ping_pong_hmac_wrong_secret() {
init_logging!();
let secret = "hello hmac ping pong";

http::with_hmac_server(secret, |server| {
Expand Down

0 comments on commit 007aa62

Please sign in to comment.