diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/hooks/sed.rs | 13 | ||||
| -rw-r--r-- | src/lib.rs | 6 |
2 files changed, 12 insertions, 7 deletions
diff --git a/src/hooks/sed.rs b/src/hooks/sed.rs index 8ae1a18..d46a9bf 100644 --- a/src/hooks/sed.rs +++ b/src/hooks/sed.rs @@ -83,9 +83,8 @@ impl Sed { #[cfg(test)] mod tests { use super::*; - use test::Bencher; - fn populate_log() -> Sed { + pub fn populate_log() -> Sed { let mut sed = Sed::new(); sed.log_msg( @@ -210,10 +209,16 @@ mod tests { "<user> this is a long message which be will replaced" ) } +} + +#[cfg(all(test, feature = "bench"))] +mod bench { + use super::*; + use test::Bencher; #[bench] fn bench_replace(b: &mut Bencher) { - let mut sed = populate_log(); + let mut sed = tests::populate_log(); b.iter(|| { sed.find_and_replace(&Message { tags: None, @@ -225,7 +230,7 @@ mod tests { #[bench] fn bench_replace_complex(b: &mut Bencher) { - let mut sed = populate_log(); + let mut sed = tests::populate_log(); b.iter(|| { sed.find_and_replace(&Message { tags: None, @@ -1,4 +1,5 @@ -#![feature(test)] +#![cfg_attr(all(test, feature = "bench"), feature(test))] +#[cfg(all(test, feature = "bench"))] extern crate test; use anyhow::Result; @@ -19,7 +20,6 @@ macro_rules! reply { }; } - pub struct Bot { pub config: config::Config, pub irc_client: irc::client::Client, @@ -37,7 +37,7 @@ impl Bot { info!("using password from env var"); config.user.password = var } - Err(_) => () + Err(_) => (), } let irc_client = Client::from_config(config.clone().into()).await?; |
