Skip to content

Commit fd36b99

Browse files
committed
Added options to the CLI to choose to execute the testing and the benchmarking
1 parent 1de83b6 commit fd36b99

File tree

1 file changed

+40
-30
lines changed

1 file changed

+40
-30
lines changed

test_suite/src/main.rs

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ struct Args {
1919
/// Optional path to the regex database file
2020
#[arg(long, short, default_value_t = String::from(constants::DEFAULT_DATABASE_PATH))]
2121
db: String,
22+
/// If you want to run the testing
23+
#[arg(long, short)]
24+
test: bool,
25+
/// If you want to run the benchmarking
26+
#[arg(long, short)]
27+
bench: bool,
2228
}
2329

2430
fn main() -> Result<(), Box<dyn Error>> {
@@ -56,40 +62,44 @@ fn main() -> Result<(), Box<dyn Error>> {
5662
continue;
5763
}
5864
}
59-
match test_regex(&regex_input, code) {
60-
Ok(test_result) => {
61-
info!(
62-
"test passed correctly for regex {}:\n{}",
63-
regex_input.regex.complete_regex(),
64-
test_result
65-
);
66-
}
67-
Err(err) => match err.downcast_ref() {
68-
Some(tester::Error::TestFailed(test_result)) => {
69-
error!(
70-
"test failed for regex {}:\n{}",
65+
if args.test {
66+
match test_regex(&regex_input, code) {
67+
Ok(test_result) => {
68+
info!(
69+
"test passed correctly for regex {}:\n{}",
7170
regex_input.regex.complete_regex(),
7271
test_result
73-
)
72+
);
7473
}
75-
None => error!("error downcasting the anyhow::Error"),
76-
},
74+
Err(err) => match err.downcast_ref() {
75+
Some(tester::Error::TestFailed(test_result)) => {
76+
error!(
77+
"test failed for regex {}:\n{}",
78+
regex_input.regex.complete_regex(),
79+
test_result
80+
)
81+
}
82+
None => error!("error downcasting the anyhow::Error"),
83+
},
84+
}
7785
}
78-
if regex_input.with_bench || benchmark_all {
79-
match execute_count_gate_command() {
80-
Ok(mut bench_result) => {
81-
info!("benchmark results:\n{}", bench_result);
82-
// Changes the data needed to write the report.
83-
bench_result.regex = regex_input.regex.complete_regex();
84-
bench_result.with_gen_substr = regex_input.gen_substrs;
85-
bench_report.push_result(bench_result);
86-
}
87-
Err(err) => {
88-
error!(
89-
"error running the benchmark for regex {}: {:?}",
90-
regex_input.regex.complete_regex(),
91-
err
92-
)
86+
if args.bench {
87+
if regex_input.with_bench || benchmark_all {
88+
match execute_count_gate_command() {
89+
Ok(mut bench_result) => {
90+
info!("benchmark results:\n{}", bench_result);
91+
// Changes the data needed to write the report.
92+
bench_result.regex = regex_input.regex.complete_regex();
93+
bench_result.with_gen_substr = regex_input.gen_substrs;
94+
bench_report.push_result(bench_result);
95+
}
96+
Err(err) => {
97+
error!(
98+
"error running the benchmark for regex {}: {:?}",
99+
regex_input.regex.complete_regex(),
100+
err
101+
)
102+
}
93103
}
94104
}
95105
}

0 commit comments

Comments
 (0)