aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Cargo.toml5
-rw-r--r--src/hooks/sed.rs13
-rw-r--r--src/lib.rs6
3 files changed, 17 insertions, 7 deletions
diff --git a/Cargo.toml b/Cargo.toml
index b96a380..2a146dd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -29,5 +29,10 @@ sedregex = { version = "0.2", git = "https://gitlab.com/audron/sedregex" }
rand = "0.8.3"
+[features]
+default = []
+
+bench = []
+
[workspace]
members = ["macros"]
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,
diff --git a/src/lib.rs b/src/lib.rs
index ca2451f..220c3af 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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?;