1; Functions names start with `Test`
2(
3 (
4 (function_declaration name: (_) @run
5 (#match? @run "^Test.*"))
6 ) @_
7 (#set! tag go-test)
8)
9
10; `t.Run`
11(
12 (
13 (call_expression
14 function: (
15 selector_expression
16 field: _ @run @_name
17 (#eq? @_name "Run")
18 )
19 arguments: (
20 argument_list
21 .
22 (interpreted_string_literal) @_subtest_name
23 .
24 (func_literal
25 parameters: (
26 parameter_list
27 (parameter_declaration
28 name: (identifier) @_param_name
29 type: (pointer_type
30 (qualified_type
31 package: (package_identifier) @_pkg
32 name: (type_identifier) @_type
33 (#eq? @_pkg "testing")
34 (#eq? @_type "T")
35 )
36 )
37 )
38 )
39 ) @_second_argument
40 )
41 )
42 ) @_
43 (#set! tag go-subtest)
44)
45
46; Functions names start with `Benchmark`
47(
48 (
49 (function_declaration name: (_) @run @_name
50 (#match? @_name "^Benchmark.+"))
51 ) @_
52 (#set! tag go-benchmark)
53)
54
55; go run
56(
57 (
58 (function_declaration name: (_) @run
59 (#eq? @run "main"))
60 ) @_
61 (#set! tag go-main)
62)