Skip to content

Commit

Permalink
Merge pull request #456 from hyperium/beta-feature
Browse files Browse the repository at this point in the history
test(beta): enable testing on beta rustc
  • Loading branch information
seanmonstar committed Apr 15, 2015
2 parents f223312 + 55b37f0 commit eab8fcd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cache:
script:
- cargo build
- cargo test
- cargo bench
- cargo bench --features nightly

after_success: |
[ $TRAVIS_BRANCH = master ] &&
Expand Down
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ typeable = "*"
[dev-dependencies]
env_logger = "*"

[features]
nightly = []
1 change: 1 addition & 0 deletions src/header/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
9 changes: 9 additions & 0 deletions src/header/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ mod tests {
Accept, Host, qitem};
use httparse;

#[cfg(feature = "nightly")]
use test::Bencher;

// Slice.position_elem is unstable
Expand Down Expand Up @@ -575,6 +576,7 @@ mod tests {
}
}

#[cfg(feature = "nightly")]
#[bench]
fn bench_headers_new(b: &mut Bencher) {
b.iter(|| {
Expand All @@ -584,38 +586,44 @@ 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();
headers.set(ContentLength(11));
b.iter(|| assert_eq!(headers.get::<ContentLength>(), Some(&ContentLength(11))))
}

#[cfg(feature = "nightly")]
#[bench]
fn bench_headers_get_miss(b: &mut Bencher) {
let headers = Headers::new();
b.iter(|| assert!(headers.get::<ContentLength>().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();
headers.set(ContentLength(11));
b.iter(|| assert!(headers.has::<ContentLength>()))
}

#[cfg(feature = "nightly")]
#[bench]
fn bench_headers_view_is(b: &mut Bencher) {
let mut headers = Headers::new();
Expand All @@ -625,6 +633,7 @@ mod tests {
b.iter(|| assert!(view.is::<ContentLength>()))
}

#[cfg(feature = "nightly")]
#[bench]
fn bench_headers_fmt(b: &mut Bencher) {
let mut headers = Headers::new();
Expand Down
2 changes: 2 additions & 0 deletions src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -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
//!
Expand Down Expand Up @@ -140,7 +140,7 @@ extern crate typeable;
#[macro_use]
extern crate log;

#[cfg(test)]
#[cfg(all(test, feature = "nightly"))]
extern crate test;


Expand Down

0 comments on commit eab8fcd

Please sign in to comment.