Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
languages: Exclude TestMain from Go runnables (#46575)
Lev Zakharov64c3e8a84849
diff --git a/crates/languages/src/go.rs b/crates/languages/src/go.rsindex 917c07cb927..7a287923c83 100644--- a/crates/languages/src/go.rs+++ b/crates/languages/src/go.rs@@ -847,6 +847,40 @@ mod tests {);}+ #[gpui::test]+ fn test_go_test_main_ignored(cx: &mut TestAppContext) {+ let language = language("go", tree_sitter_go::LANGUAGE.into());++ let example_test = r#"+ package main++ func TestMain(m *testing.M) {+ os.Exit(m.Run())+ }+ "#;++ let buffer =+ cx.new(|cx| crate::Buffer::local(example_test, cx).with_language(language.clone(), cx));+ cx.executor().run_until_parked();++ let runnables: Vec<_> = buffer.update(cx, |buffer, _| {+ let snapshot = buffer.snapshot();+ snapshot.runnable_ranges(0..example_test.len()).collect()+ });++ let tag_strings: Vec<String> = runnables+ .iter()+ .flat_map(|r| &r.runnable.tags)+ .map(|tag| tag.0.to_string())+ .collect();++ assert!(+ !tag_strings.contains(&"go-test".to_string()),+ "Should NOT find go-test tag, found: {:?}",+ tag_strings+ );+ }+#[gpui::test]fn test_testify_suite_detection(cx: &mut TestAppContext) {let language = language("go", tree_sitter_go::LANGUAGE.into());diff --git a/crates/languages/src/go/runnables.scm b/crates/languages/src/go/runnables.scmindex a5081a21190..82960ec2c67 100644--- a/crates/languages/src/go/runnables.scm+++ b/crates/languages/src/go/runnables.scm@@ -2,7 +2,8 @@(((function_declaration name: (_) @run- (#match? @run "^Test.*"))+ (#match? @run "^Test.*")+ (#not-match? @run "^TestMain$"))) @_(#set! tag go-test))