diff --git a/Cargo.toml b/Cargo.toml index 6846d6d..e1a489a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ pgn-lexer = { git = "https://github.com/datawater/pgn-lexer" } [features] safe_u24 = [] +benchmark = [] [profile.release] opt-level = 3 diff --git a/src/main.rs b/src/main.rs index 9487d43..6eca34e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,5 @@ // TODO: Define and Write documentation for the CMBR Standard. // TODO: Seperate the cli and libcmbr -#![feature(test)] #![allow(non_upper_case_globals)] mod cmbr; diff --git a/tests/pgn/ast.rs b/tests/pgn/ast.rs index fca09f1..ca98981 100644 --- a/tests/pgn/ast.rs +++ b/tests/pgn/ast.rs @@ -1,3 +1,5 @@ +#[cfg(feature = "benchmark")] +#[feature(test)] extern crate test; #[cfg(test)] @@ -6,7 +8,9 @@ mod pgn_tests { use project_root::get_project_root; use std::fs::File; + #[cfg(feature = "benchmark")] use super::test::Bencher; + use crate::pgn; #[test] @@ -40,6 +44,7 @@ mod pgn_tests { assert_eq!(format!("{:?}", ast), ast_expected); } + #[cfg(feature = "benchmark")] #[bench] fn bench_ast(b: &mut Bencher) { let file_path = get_project_root().unwrap().join("data/twic1544.pgn"); diff --git a/tests/pgn/lex.rs b/tests/pgn/lex.rs index 6d947d4..e264dd9 100644 --- a/tests/pgn/lex.rs +++ b/tests/pgn/lex.rs @@ -1,3 +1,5 @@ +#[cfg(feature = "benchmark")] +#[feature(test)] extern crate test; #[cfg(test)] @@ -7,7 +9,9 @@ mod pgn_tests { use project_root::get_project_root; use std::{collections::VecDeque, fs::File}; + #[cfg(feature = "benchmark")] use super::test::Bencher; + use crate::pgn; #[test] @@ -108,6 +112,7 @@ mod pgn_tests { assert_eq!(tokens_expected, tokens); } + #[cfg(feature = "benchmark")] #[bench] fn bench_lex(b: &mut Bencher) { let file_path = get_project_root().unwrap().join("data/twic1544.pgn");