Skip to content

Commit 4a4c01b

Browse files
committed
ignore empty arguments instead of Some("")
1 parent 65c90a1 commit 4a4c01b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

site/src/request_handlers/github.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,12 @@ fn parse_benchmark_parameters<'a>(
224224
mut args: HashMap<&'a str, &'a str>,
225225
) -> Result<BenchmarkParameters<'a>, String> {
226226
let mut params = BenchmarkParameters {
227-
include: args.remove("include"),
228-
exclude: args.remove("exclude"),
227+
include: args.remove("include").filter(|s| !s.is_empty()),
228+
exclude: args.remove("exclude").filter(|s| !s.is_empty()),
229229
runs: None,
230-
backends: args.remove("backends"),
230+
backends: args.remove("backends").filter(|s| !s.is_empty()),
231231
};
232-
if let Some(runs) = args.remove("runs") {
232+
if let Some(runs) = args.remove("runs").filter(|s| !s.is_empty()) {
233233
let Ok(runs) = runs.parse::<u32>() else {
234234
return Err(format!("Cannot parse runs {runs} as a number"));
235235
};
@@ -484,4 +484,16 @@ Otherwise LGTM."#),
484484
insta::assert_compact_debug_snapshot!(parse_queue_command("@rust-timer queue include=hello exclude=ripgrep runs=3 backends=Llvm"),
485485
@r#"Some(Ok(QueueCommand { params: BenchmarkParameters { include: Some("hello"), exclude: Some("ripgrep"), runs: Some(3), backends: Some("Llvm") } }))"#);
486486
}
487+
488+
#[test]
489+
fn no_empty_arguments_thank_you() {
490+
insta::assert_compact_debug_snapshot!(parse_queue_command("@rust-timer queue include="),
491+
@"Some(Ok(QueueCommand { params: BenchmarkParameters { include: None, exclude: None, runs: None, backends: None } }))");
492+
insta::assert_compact_debug_snapshot!(parse_queue_command("@rust-timer queue exclude="),
493+
@"Some(Ok(QueueCommand { params: BenchmarkParameters { include: None, exclude: None, runs: None, backends: None } }))");
494+
insta::assert_compact_debug_snapshot!(parse_queue_command("@rust-timer queue runs="),
495+
@"Some(Ok(QueueCommand { params: BenchmarkParameters { include: None, exclude: None, runs: None, backends: None } }))");
496+
insta::assert_compact_debug_snapshot!(parse_queue_command("@rust-timer queue backends="),
497+
@"Some(Ok(QueueCommand { params: BenchmarkParameters { include: None, exclude: None, runs: None, backends: None } }))");
498+
}
487499
}

0 commit comments

Comments
 (0)