Escape carets (^) in Go test regex (#27746)
This is a follow up to https://github.com/zed-industries/zed/pull/14821, which escaped `$` but not `^`. This is fine for `bash`, but causes issues with `zsh`. This change escapes the `^`. I tested this against `bash`, `zsh` and `fish` I suspect such escaping would probably need to be done at some shell-specific layer of the code, but for now it seems like the tasks provided by the `ContextProvider` are supposed to be shell agnostic. To reproduce the original issue: 1. Create a Go test file in a module that just contains a single test `TestABC`. 2. Run `zsh -i -c "go test -run ^TestABC\$"` which is what Zed tries to run when the task for a specific Go test is executed. 3. An error that there are no tests to run will be produced even though there is a test. 4. Run `zsh -i -c "go test -run \^TestABC\$"` (note the backslash before ^). 5. The test will run successfully. Example: ``` go package bar import "testing" func TestABC(t *testing.T) {} ``` Release Notes: - fix: Escape the ^ in the Go test -run regex to improve shell compatibility (notably with zsh).
This commit is contained in:
parent
9e38c45a9b
commit
5e286897d3
1 changed files with 5 additions and 5 deletions
|
@ -528,7 +528,7 @@ impl ContextProvider for GoContextProvider {
|
||||||
args: vec![
|
args: vec![
|
||||||
"test".into(),
|
"test".into(),
|
||||||
"-run".into(),
|
"-run".into(),
|
||||||
format!("^{}\\$", VariableName::Symbol.template_value(),),
|
format!("\\^{}\\$", VariableName::Symbol.template_value(),),
|
||||||
],
|
],
|
||||||
tags: vec!["go-test".to_owned()],
|
tags: vec!["go-test".to_owned()],
|
||||||
cwd: package_cwd.clone(),
|
cwd: package_cwd.clone(),
|
||||||
|
@ -561,7 +561,7 @@ impl ContextProvider for GoContextProvider {
|
||||||
"-v".into(),
|
"-v".into(),
|
||||||
"-run".into(),
|
"-run".into(),
|
||||||
format!(
|
format!(
|
||||||
"^{}\\$/^{}\\$",
|
"\\^{}\\$/\\^{}\\$",
|
||||||
VariableName::Symbol.template_value(),
|
VariableName::Symbol.template_value(),
|
||||||
GO_SUBTEST_NAME_TASK_VARIABLE.template_value(),
|
GO_SUBTEST_NAME_TASK_VARIABLE.template_value(),
|
||||||
),
|
),
|
||||||
|
@ -580,9 +580,9 @@ impl ContextProvider for GoContextProvider {
|
||||||
args: vec![
|
args: vec![
|
||||||
"test".into(),
|
"test".into(),
|
||||||
"-benchmem".into(),
|
"-benchmem".into(),
|
||||||
"-run=^$".into(),
|
"-run='^$'".into(),
|
||||||
"-bench".into(),
|
"-bench".into(),
|
||||||
format!("^{}\\$", VariableName::Symbol.template_value()),
|
format!("\\^{}\\$", VariableName::Symbol.template_value()),
|
||||||
],
|
],
|
||||||
cwd: package_cwd.clone(),
|
cwd: package_cwd.clone(),
|
||||||
tags: vec!["go-benchmark".to_owned()],
|
tags: vec!["go-benchmark".to_owned()],
|
||||||
|
@ -599,7 +599,7 @@ impl ContextProvider for GoContextProvider {
|
||||||
"test".into(),
|
"test".into(),
|
||||||
"-fuzz=Fuzz".into(),
|
"-fuzz=Fuzz".into(),
|
||||||
"-run".into(),
|
"-run".into(),
|
||||||
format!("^{}\\$", VariableName::Symbol.template_value(),),
|
format!("\\^{}\\$", VariableName::Symbol.template_value(),),
|
||||||
],
|
],
|
||||||
tags: vec!["go-fuzz".to_owned()],
|
tags: vec!["go-fuzz".to_owned()],
|
||||||
cwd: package_cwd.clone(),
|
cwd: package_cwd.clone(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue