-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
Copy pathrunnables.scm
69 lines (65 loc) · 1.33 KB
/
runnables.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
; Functions names start with `Test`
(
(
(function_declaration name: (_) @run
(#match? @run "^Test.*"))
) @_
(#set! tag go-test)
)
; `go:generate` comments
(
((comment) @_comment @run
(#match? @_comment "^//go:generate"))
(#set! tag go-generate)
)
; `t.Run`
(
(
(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)
)