diff --git a/crates/languages/src/go.rs b/crates/languages/src/go.rs index 73e9b162f4d6e76c4a42d4e24accfd90e79733c9..4b87a6fd7d2aae9e9c2df55357218d62c1734084 100644 --- a/crates/languages/src/go.rs +++ b/crates/languages/src/go.rs @@ -706,7 +706,7 @@ impl ContextProvider for GoContextProvider { "-v".into(), "-run".into(), format!( - "'^{}$/^{}$'", + "\\^{}\\$/\\^{}\\$", VariableName::Symbol.template_value(), GO_SUBTEST_NAME_TASK_VARIABLE.template_value(), ), diff --git a/crates/project/tests/integration/debugger.rs b/crates/project/tests/integration/debugger.rs index 61bba78c74baec2e48b172043b3b504ccf32dba9..a9ac1c78ce85c8752c3100c180ab0b06657d85c4 100644 --- a/crates/project/tests/integration/debugger.rs +++ b/crates/project/tests/integration/debugger.rs @@ -173,6 +173,46 @@ mod go_locator { ); } + #[gpui::test] + async fn test_go_locator_subtest(_: &mut TestAppContext) { + let locator = GoLocator; + let delve = DebugAdapterName("Delve".into()); + + // The `go-subtest` task template uses the \^...\$ format for the `-run` + // arg so the GoLocator strips the shell escaping before passing it to + // Delve. Previously the template used single quotes ('^...$') which + // Delve passed literally to the test binary, breaking all subtests. + let task = TaskTemplate { + label: "test subtest".into(), + command: "go".into(), + args: vec![ + "test".to_string(), + "-v".to_string(), + "-run".to_string(), + "\\^TestFoo\\$/\\^simple_subtest\\$".to_string(), + ], + ..Default::default() + }; + let result = locator.create_scenario(&task, "", &delve).await.unwrap(); + let config: DelveLaunchRequest = serde_json::from_value(result.config).unwrap(); + assert_eq!( + config, + DelveLaunchRequest { + request: "launch".to_string(), + mode: "test".to_string(), + program: ".".to_string(), + build_flags: vec![], + args: vec![ + "-test.v".to_string(), + "-test.run".to_string(), + "^TestFoo$/^simple_subtest$".to_string(), + ], + env: Default::default(), + cwd: None, + } + ); + } + #[gpui::test] async fn test_skip_unsupported_go_commands(_: &mut TestAppContext) { let locator = GoLocator;