diff --git a/.travis.yml b/.travis.yml index 99e1214b35..f10d54bf0e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ cache: script: - cargo build - cargo test - - cargo bench + - cargo bench --features nightly after_success: | [ $TRAVIS_BRANCH = master ] && diff --git a/Cargo.toml b/Cargo.toml index f1efdc7d09..5ecadd2f15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,3 +28,5 @@ typeable = "*" [dev-dependencies] env_logger = "*" +[features] +nightly = [] diff --git a/src/header/common/mod.rs b/src/header/common/mod.rs index 8a882a9116..8168d9656c 100644 --- a/src/header/common/mod.rs +++ b/src/header/common/mod.rs @@ -48,6 +48,7 @@ pub use self::vary::Vary; macro_rules! bench_header( ($name:ident, $ty:ty, $value:expr) => { #[cfg(test)] + #[cfg(feature = "nightly")] mod $name { use test::Bencher; use super::*; diff --git a/src/header/mod.rs b/src/header/mod.rs index b6463d5a13..e4b5734928 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -390,6 +390,7 @@ mod tests { Accept, Host, qitem}; use httparse; + #[cfg(feature = "nightly")] use test::Bencher; // Slice.position_elem is unstable @@ -575,6 +576,7 @@ mod tests { } } + #[cfg(feature = "nightly")] #[bench] fn bench_headers_new(b: &mut Bencher) { b.iter(|| { @@ -584,12 +586,14 @@ mod tests { }) } + #[cfg(feature = "nightly")] #[bench] fn bench_headers_from_raw(b: &mut Bencher) { let raw = raw!(b"Content-Length: 10"); b.iter(|| Headers::from_raw(&raw).unwrap()) } + #[cfg(feature = "nightly")] #[bench] fn bench_headers_get(b: &mut Bencher) { let mut headers = Headers::new(); @@ -597,18 +601,21 @@ mod tests { b.iter(|| assert_eq!(headers.get::(), Some(&ContentLength(11)))) } + #[cfg(feature = "nightly")] #[bench] fn bench_headers_get_miss(b: &mut Bencher) { let headers = Headers::new(); b.iter(|| assert!(headers.get::().is_none())) } + #[cfg(feature = "nightly")] #[bench] fn bench_headers_set(b: &mut Bencher) { let mut headers = Headers::new(); b.iter(|| headers.set(ContentLength(12))) } + #[cfg(feature = "nightly")] #[bench] fn bench_headers_has(b: &mut Bencher) { let mut headers = Headers::new(); @@ -616,6 +623,7 @@ mod tests { b.iter(|| assert!(headers.has::())) } + #[cfg(feature = "nightly")] #[bench] fn bench_headers_view_is(b: &mut Bencher) { let mut headers = Headers::new(); @@ -625,6 +633,7 @@ mod tests { b.iter(|| assert!(view.is::())) } + #[cfg(feature = "nightly")] #[bench] fn bench_headers_fmt(b: &mut Bencher) { let mut headers = Headers::new(); diff --git a/src/http.rs b/src/http.rs index 3f00ec00f3..b05c0e6b4e 100644 --- a/src/http.rs +++ b/src/http.rs @@ -518,8 +518,10 @@ mod tests { parse_request(&mut buf).unwrap(); } + #[cfg(feature = "nightly")] use test::Bencher; + #[cfg(feature = "nightly")] #[bench] fn bench_parse_incoming(b: &mut Bencher) { use buffer::BufReader; diff --git a/src/lib.rs b/src/lib.rs index dbf58c4f59..24392bafaf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ #![doc(html_root_url = "https://hyperium.github.io/hyper/hyper/index.html")] #![deny(missing_docs)] #![cfg_attr(test, deny(warnings))] -#![cfg_attr(test, feature(test))] +#![cfg_attr(all(test, feature = "nightly"), feature(test))] //! # Hyper //! @@ -140,7 +140,7 @@ extern crate typeable; #[macro_use] extern crate log; -#[cfg(test)] +#[cfg(all(test, feature = "nightly"))] extern crate test;