@@ -33,35 +33,14 @@ which is extracted to a temporary directory. The relative path to the .txt
33
33
file is used as the subtest name. The preliminary section of the file
34
34
(before the first archive entry) is a free-form comment.
35
35
36
- These tests were inspired by (and in many places copied from) a previous
37
- iteration of the marker tests built on top of the packagestest framework.
38
- Key design decisions motivating this reimplementation are as follows:
39
- - The old tests had a single global session, causing interaction at a
40
- distance and several awkward workarounds.
41
- - The old tests could not be safely parallelized, because certain tests
42
- manipulated the server options
43
- - Relatedly, the old tests did not have a logic grouping of assertions into
44
- a single unit, resulting in clusters of files serving clusters of
45
- entangled assertions.
46
- - The old tests used locations in the source as test names and as the
47
- identity of golden content, meaning that a single edit could change the
48
- name of an arbitrary number of subtests, and making it difficult to
49
- manually edit golden content.
50
- - The old tests did not hew closely to LSP concepts, resulting in, for
51
- example, each marker implementation doing its own position
52
- transformations, and inventing its own mechanism for configuration.
53
- - The old tests had an ad-hoc session initialization process. The integration
54
- test environment has had more time devoted to its initialization, and has a
55
- more convenient API.
56
- - The old tests lacked documentation, and often had failures that were hard
57
- to understand. By starting from scratch, we can revisit these aspects.
58
-
59
36
# Special files
60
37
61
38
There are several types of file within the test archive that are given special
62
39
treatment by the test runner:
40
+
63
41
- "skip": the presence of this file causes the test to be skipped, with
64
42
the file content used as the skip message.
43
+
65
44
- "flags": this file is treated as a whitespace-separated list of flags
66
45
that configure the MarkerTest instance. Supported flags:
67
46
-min_go=go1.20 sets the minimum Go version for the test;
@@ -78,21 +57,28 @@ treatment by the test runner:
78
57
-filter_keywords=false disables the filtering of keywords from
79
58
completion results.
80
59
TODO(rfindley): support flag values containing whitespace.
60
+
81
61
- "settings.json": this file is parsed as JSON, and used as the
82
62
session configuration (see gopls/doc/settings.md)
63
+
83
64
- "capabilities.json": this file is parsed as JSON client capabilities,
84
65
and applied as an overlay over the default editor client capabilities.
85
66
see https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#clientCapabilities
86
67
for more details.
68
+
87
69
- "env": this file is parsed as a list of VAR=VALUE fields specifying the
88
70
editor environment.
71
+
89
72
- Golden files: Within the archive, file names starting with '@' are
90
73
treated as "golden" content, and are not written to disk, but instead are
91
74
made available to test methods expecting an argument of type *Golden,
92
75
using the identifier following '@'. For example, if the first parameter of
93
76
Foo were of type *Golden, the test runner would convert the identifier a
94
77
in the call @foo(a, "b", 3) into a *Golden by collecting golden file
95
- data starting with "@a/".
78
+ data starting with "@a/". As a special case, for tests that only need one
79
+ golden file, the data contained in the file "@a" is indexed in the *Golden
80
+ value by the empty string "".
81
+
96
82
- proxy files: any file starting with proxy/ is treated as a Go proxy
97
83
file. If present, these files are written to a separate temporary
98
84
directory and GOPROXY is set to file://<proxy directory>.
@@ -309,11 +295,14 @@ parameter type pairs:
309
295
310
296
Here is a complete example:
311
297
298
+ This test checks hovering over constants.
299
+
312
300
-- a.go --
313
301
package a
314
302
315
303
const abc = 0x2a //@hover("b", "abc", abc),hover(" =", "abc", abc)
316
- -- @abc/hover.md --
304
+
305
+ -- @abc --
317
306
```go
318
307
const abc untyped int = 42
319
308
```
@@ -329,13 +318,13 @@ The first argument holds the test context, including fake editor with open
329
318
files, and sandboxed directory.
330
319
331
320
Argument converters translate the "b" and "abc" arguments into locations by
332
- interpreting each one as a regular expression and finding the location of
333
- its first match on the preceding portion of the line, and the abc identifier
334
- into a dictionary of golden content containing "hover.md". Then the
335
- hoverMarker method executes a textDocument/hover LSP request at the src
336
- position, and ensures the result spans "abc", with the markdown content from
337
- hover.md. (Note that the markdown content includes the expect annotation as
338
- the doc comment.)
321
+ interpreting each one as a substring (or as a regular expression, if of the
322
+ form re"a|b") and finding the location of its first occurrence on the preceding
323
+ portion of the line, and the abc identifier into a the golden content contained
324
+ in the file @abc. Then the hoverMarker method executes a textDocument/hover LSP
325
+ request at the src position, and ensures the result spans "abc", with the
326
+ markdown content from @abc. (Note that the markdown content includes the expect
327
+ annotation as the doc comment.)
339
328
340
329
The next hover on the same line asserts the same result, but initiates the
341
330
hover immediately after "abc" in the source. This tests that we find the
0 commit comments