aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2021-09-07 12:53:01 +0200
committerMax Audron <audron@cocaine.farm>2021-09-07 12:53:01 +0200
commitd69a7f9405444e86475f615f91ba6c924a293096 (patch)
treef0434edb78d4954db9da5787397fdd514aa6c736 /src
parenthandle error cases in sed module (diff)
put benchmark behind feature flag we can compile using stable rust
Diffstat (limited to '')
-rw-r--r--src/hooks/sed.rs13
-rw-r--r--src/lib.rs6
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,
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?;
e='2021-10-20 17:40:59 +0200'>2021-10-20bump version to 1.6.2Max Audron-3/+2 2021-10-20prepare for release on crates.ioMax Audron-39/+65 2021-10-20add async docs to macro crate and bump versionMax Audron-9/+10 2021-10-20change hook errors to be logged as warningsMax Audron-3/+3 they in nearly all cases aren't critical enough to warrant an actual error messages 2021-10-20fix configuration not loading correctly on release buildsMax Audron-8/+23 2021-10-19replace sedregex crate8-rework-sedMax Audron-20/+358 This replaces the sedregex crate with our own implementation for multiple reasons: 1. We required to access the parsed regex, this required a patch to the sedregex crate which did not get merged due to an inactive dev, blocking us from publishing on crates.Io 2. We wanted to highlight the changes done in bold 3. We want to add execution of multiple chained sed commands in the future which would require more modification 2021-10-19add formatting trait for irc codesMax Audron-0/+129 add an impl off the formatting trait on String to format Strings with the typical irc formatting codes for bold, italic etc 2021-10-17fix links in readmeMax Audron-2/+2