go: Add runnables for Go (#12003)
Implemented runnables for specially for running tests for Go. I'm grateful for your feedback because this is my first experience with Rust and Zed codebase.  https://github.com/zed-industries/zed/assets/1047345/ae1abd9e-3657-4322-9c28-02d0752b5ccd Release Notes: - Added Runnables/Tasks for: - Run test functions which start with "Test" - Run subtests - Run benchmark tests - Run main function --------- Co-authored-by: Thorsten Ball <mrnugget@gmail.com> Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
This commit is contained in:
parent
5665cad250
commit
ddb551c794
4 changed files with 155 additions and 23 deletions
|
@ -1,15 +1,62 @@
|
|||
; Functions names start with `Test`
|
||||
(
|
||||
(
|
||||
(function_declaration name: (_) @run
|
||||
(#match? @run "^Test.*"))
|
||||
) @_
|
||||
(#set! tag go-test)
|
||||
(
|
||||
(function_declaration name: (_) @run
|
||||
(#match? @run "^Test.*"))
|
||||
) @_
|
||||
(#set! tag go-test)
|
||||
)
|
||||
|
||||
; `t.Run`
|
||||
(
|
||||
(
|
||||
(function_declaration name: (_) @run
|
||||
(#eq? @run "main"))
|
||||
) @_
|
||||
(#set! tag go-main)
|
||||
(
|
||||
(call_expression
|
||||
function: (
|
||||
selector_expression
|
||||
field: _ @run @_name
|
||||
(#eq? @_name "Run")
|
||||
)
|
||||
arguments: (
|
||||
argument_list
|
||||
.
|
||||
(interpreted_string_literal) @_subtest_name
|
||||
.
|
||||
(func_literal
|
||||
parameters: (
|
||||
parameter_list
|
||||
(parameter_declaration
|
||||
name: (identifier) @_param_name
|
||||
type: (pointer_type
|
||||
(qualified_type
|
||||
package: (package_identifier) @_pkg
|
||||
name: (type_identifier) @_type
|
||||
(#eq? @_pkg "testing")
|
||||
(#eq? @_type "T")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
) @_second_argument
|
||||
)
|
||||
)
|
||||
) @_
|
||||
(#set! tag go-subtest)
|
||||
)
|
||||
|
||||
; Functions names start with `Benchmark`
|
||||
(
|
||||
(
|
||||
(function_declaration name: (_) @run @_name
|
||||
(#match? @_name "^Benchmark.+"))
|
||||
) @_
|
||||
(#set! tag go-benchmark)
|
||||
)
|
||||
|
||||
; go run
|
||||
(
|
||||
(
|
||||
(function_declaration name: (_) @run
|
||||
(#eq? @run "main"))
|
||||
) @_
|
||||
(#set! tag go-main)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue