Skip to content

Commit

Permalink
Add support for go fuzz tests. Closes #23809.
Browse files Browse the repository at this point in the history
  • Loading branch information
cborup committed Feb 2, 2025
1 parent 1dd2bbe commit 10d64aa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
17 changes: 17 additions & 0 deletions crates/languages/src/go.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
9 changes: 9 additions & 0 deletions crates/languages/src/go/runnables.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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
(
(
Expand Down

0 comments on commit 10d64aa

Please sign in to comment.