@@ -10,16 +10,26 @@ Use this command to run the tests, from the gopls module:
10
10
11
11
$ go test ./internal/test/marker [-update]
12
12
13
- A marker test uses the '//@' marker syntax of the x/tools/internal/expect package
14
- to annotate source code with various information such as locations and
15
- arguments of LSP operations to be executed by the test. The syntax following
16
- '@' is parsed as a comma-separated list of ordinary Go function calls, for
17
- example
13
+ A marker test uses the '//@' syntax of the x/tools/internal/expect package to
14
+ annotate source code with various information such as locations and arguments
15
+ of LSP operations to be executed by the test. The syntax following '@' is
16
+ parsed as a comma-separated list of Go-like function calls, which we refer to
17
+ as 'markers' (or sometimes 'marks'), for example
18
18
19
- //@foo(a, "b", 3),bar(0)
19
+ //@ foo(a, "b", 3), bar(0)
20
20
21
- and delegates to a corresponding function to perform LSP-related operations.
22
- See the Marker types documentation below for a list of supported markers.
21
+ Unlike ordinary Go, the marker syntax also supports optional named arguments
22
+ using the syntax name=value. If provided, named arguments must appear after all
23
+ positional arguments, though their ordering with respect to other named
24
+ arguments does not matter. For example
25
+
26
+ //@ foo(a, "b", d=4, c=3)
27
+
28
+ Each marker causes a corresponding function to be called in the test. Some
29
+ markers are declarations; for example, @loc declares a name for a source
30
+ location. Others have effects, such as executing an LSP operation and asserting
31
+ that it behaved as expected. See the Marker types documentation below for the
32
+ list of all supported markers.
23
33
24
34
Each call argument is converted to the type of the corresponding parameter of
25
35
the designated function. The conversion logic may use the surrounding context,
@@ -39,26 +49,30 @@ There are several types of file within the test archive that are given special
39
49
treatment by the test runner:
40
50
41
51
- "skip": the presence of this file causes the test to be skipped, with
42
- the file content used as the skip message.
52
+ its content used as the skip message.
43
53
44
54
- "flags": this file is treated as a whitespace-separated list of flags
45
55
that configure the MarkerTest instance. Supported flags:
46
- -{min,max}_go=go1.20 sets the {min,max}imum Go version for the test
47
- (inclusive)
48
- -cgo requires that CGO_ENABLED is set and the cgo tool is available
56
+
57
+ -{min,max}_go=go1.20 sets the {min,max}imum Go runtime version for the test
58
+ (inclusive).
59
+ -{min,max}_go_command=go1.20 sets the {min,max}imum Go command version for
60
+ the test (inclusive).
61
+ -cgo requires that CGO_ENABLED is set and the cgo tool is available.
49
62
-write_sumfile=a,b,c instructs the test runner to generate go.sum files
50
63
in these directories before running the test.
51
64
-skip_goos=a,b,c instructs the test runner to skip the test for the
52
65
listed GOOS values.
53
66
-skip_goarch=a,b,c does the same for GOARCH.
54
- -ignore_extra_diags suppresses errors for unmatched diagnostics
55
67
TODO(rfindley): using build constraint expressions for -skip_go{os,arch} would
56
68
be clearer.
69
+ -ignore_extra_diags suppresses errors for unmatched diagnostics
57
70
-filter_builtins=false disables the filtering of builtins from
58
71
completion results.
59
72
-filter_keywords=false disables the filtering of keywords from
60
73
completion results.
61
74
-errors_ok=true suppresses errors for Error level log entries.
75
+
62
76
TODO(rfindley): support flag values containing whitespace.
63
77
64
78
- "settings.json": this file is parsed as JSON, and used as the
@@ -106,11 +120,10 @@ The following markers are supported within marker tests:
106
120
107
121
If end is set, the location is defined to be between start.Start and end.End.
108
122
109
- Exactly one of edit, result, or err must be set.
110
- If edit is set, it is a golden reference to the edits resulting from the code action.
111
- If result is set, it is a golden reference to the full set of changed files
112
- resulting from the code action.
113
- If err is set, it is the code action error.
123
+ Exactly one of edit, result, or err must be set. If edit is set, it is a
124
+ golden reference to the edits resulting from the code action. If result is
125
+ set, it is a golden reference to the full set of changed files resulting
126
+ from the code action. If err is set, it is the code action error.
114
127
115
128
- codelens(location, title): specifies that a codelens is expected at the
116
129
given location, with given title. Must be used in conjunction with
@@ -131,8 +144,8 @@ The following markers are supported within marker tests:
131
144
The specified location must match the start position of the diagnostic,
132
145
but end positions are ignored unless exact=true.
133
146
134
- TODO(adonovan): in the older marker framework, the annotation asserted
135
- two additional fields (source="compiler", kind="error"). Restore them using
147
+ TODO(adonovan): in the older marker framework, the annotation asserted two
148
+ additional fields (source="compiler", kind="error"). Restore them using
136
149
optional named arguments.
137
150
138
151
- def(src, dst location): performs a textDocument/definition request at
0 commit comments