Skip to content

Commit

Permalink
Escape runnable code lenses
Browse files Browse the repository at this point in the history
Summary:
It can happen that a test case name/group contains a special character, which can conflict with the Buck2 regex mechanism, leading to invalid results and tests not being correctly run.

Ensure we escape both the test name and group, for running and debugging purposes.

Reviewed By: alanz

Differential Revision: D66452716

fbshipit-source-id: da91350d56b7f3a816a37a303b77a4cfde8af391
  • Loading branch information
robertoaloi authored and facebook-github-bot committed Nov 25, 2024
1 parent 5940cc8 commit 2d4aa02
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/ide/src/runnables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ impl Runnable {
RunnableKind::Test {
suite, case, group, ..
} => {
let group = group.name();
format!("{suite} - {group}.{case}")
let escaped_group = regex::escape(&group.name());
let escaped_case = regex::escape(case);
format!("{suite} - {escaped_group}.{escaped_case}")
}
RunnableKind::Suite => "".to_string(),
}
Expand All @@ -66,8 +67,9 @@ impl Runnable {
group,
..
} => {
let group = group.name();
format!("{app_name}:{suite} - {group}.{case}$")
let escaped_group = regex::escape(&group.name());
let escaped_case = regex::escape(case);
format!("{app_name}:{suite} - {escaped_group}.{escaped_case}$")
}
RunnableKind::Suite => "".to_string(),
}
Expand Down

0 comments on commit 2d4aa02

Please sign in to comment.