Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Add support for Go fuzz tests (#24107)

Christian Borupf45d58f01abc
diff --git a/crates/languages/src/go.rs b/crates/languages/src/go.rs
index f5398209ef5..94815a9951c 100644
--- a/crates/languages/src/go.rs
+++ b/crates/languages/src/go.rs
@@ -586,6 +586,23 @@ impl ContextProvider for GoContextProvider {
tags: vec!["go-benchmark".to_owned()],
..TaskTemplate::default()
},
+ TaskTemplate {
+ label: format!(
+ "go test {} -fuzz=Fuzz -run {}",
+ GO_PACKAGE_TASK_VARIABLE.template_value(),
+ VariableName::Symbol.template_value(),
+ ),
+ command: "go".into(),
+ args: vec![
+ "test".into(),
+ "-fuzz=Fuzz".into(),
+ "-run".into(),
+ format!("^{}\\$", VariableName::Symbol.template_value(),),
+ ],
+ tags: vec!["go-fuzz".to_owned()],
+ cwd: package_cwd.clone(),
+ ..TaskTemplate::default()
+ },
TaskTemplate {
label: format!("go run {}", GO_PACKAGE_TASK_VARIABLE.template_value(),),
command: "go".into(),
diff --git a/crates/languages/src/go/runnables.scm b/crates/languages/src/go/runnables.scm
index eb643c448e7..8d5f4375c13 100644
--- a/crates/languages/src/go/runnables.scm
+++ b/crates/languages/src/go/runnables.scm
@@ -59,6 +59,15 @@
(#set! tag go-benchmark)
)
+; Functions names start with `Fuzz`
+(
+ (
+ (function_declaration name: (_) @run @_name
+ (#match? @_name "^Fuzz"))
+ ) @_
+ (#set! tag go-fuzz)
+)
+
; go run
(
(