From 3fd127c2f6be8ef77bb0b7d79c2664d4cc792271 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Fri, 19 Jul 2024 18:05:31 +0200 Subject: [PATCH] go: Fix quoting of targeting expression for non-fish shells (#14821) This fixes #14818. The change in #14055 broke the tasks in `zsh` (and I suspect in `bash`, `sh` too), because what was executed was NOT $ go test . -run '^TestThis$' but instead this: $ go test . -run \'^TestThis$\' And in `zsh` this means that `'` is part of the argument passed to `go`, which means the targeting string is wrong. Since the problem in `fish` doesn't seem to be the `^` but the `$`, we can only escape that, which makes the escaped string work in `zsh` and `fish` and `bash` (in which I've tested this change here) Release Notes: - go: Fix running single tests by changing the quoted expression in the `go test` command to work again in `bash`, `zsh`, etc. ([#14818](https://github.com/zed-industries/zed/issues/14818)) --- crates/languages/src/go.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/languages/src/go.rs b/crates/languages/src/go.rs index 17a002f97b886487845a93dc6344e611ede6d973..08c4a40ad93be6282fe90e2bc1d424b45dd1d5f2 100644 --- a/crates/languages/src/go.rs +++ b/crates/languages/src/go.rs @@ -518,7 +518,7 @@ impl ContextProvider for GoContextProvider { "test".into(), GO_PACKAGE_TASK_VARIABLE.template_value(), "-run".into(), - format!("'^{}$'", VariableName::Symbol.template_value(),), + format!("^{}\\$", VariableName::Symbol.template_value(),), ], tags: vec!["go-test".to_owned()], ..TaskTemplate::default() @@ -549,7 +549,7 @@ impl ContextProvider for GoContextProvider { "-v".into(), "-run".into(), format!( - "'^{}$/^{}$'", + "^{}\\$/^{}\\$", VariableName::Symbol.template_value(), GO_SUBTEST_NAME_TASK_VARIABLE.template_value(), ), @@ -570,7 +570,7 @@ impl ContextProvider for GoContextProvider { "-benchmem".into(), "-run=^$".into(), "-bench".into(), - format!("'^{}$'", VariableName::Symbol.template_value()), + format!("^{}\\$", VariableName::Symbol.template_value()), ], tags: vec!["go-benchmark".to_owned()], ..TaskTemplate::default()