@@ -33,35 +33,14 @@ which is extracted to a temporary directory. The relative path to the .txt
3333file is used as the subtest name. The preliminary section of the file
3434(before the first archive entry) is a free-form comment.
3535
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-
5936# Special files
6037
6138There are several types of file within the test archive that are given special
6239treatment by the test runner:
40+
6341 - "skip": the presence of this file causes the test to be skipped, with
6442 the file content used as the skip message.
43+
6544 - "flags": this file is treated as a whitespace-separated list of flags
6645 that configure the MarkerTest instance. Supported flags:
6746 -min_go=go1.20 sets the minimum Go version for the test;
@@ -78,21 +57,28 @@ treatment by the test runner:
7857 -filter_keywords=false disables the filtering of keywords from
7958 completion results.
8059 TODO(rfindley): support flag values containing whitespace.
60+
8161 - "settings.json": this file is parsed as JSON, and used as the
8262 session configuration (see gopls/doc/settings.md)
63+
8364 - "capabilities.json": this file is parsed as JSON client capabilities,
8465 and applied as an overlay over the default editor client capabilities.
8566 see https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#clientCapabilities
8667 for more details.
68+
8769 - "env": this file is parsed as a list of VAR=VALUE fields specifying the
8870 editor environment.
71+
8972 - Golden files: Within the archive, file names starting with '@' are
9073 treated as "golden" content, and are not written to disk, but instead are
9174 made available to test methods expecting an argument of type *Golden,
9275 using the identifier following '@'. For example, if the first parameter of
9376 Foo were of type *Golden, the test runner would convert the identifier a
9477 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+
9682 - proxy files: any file starting with proxy/ is treated as a Go proxy
9783 file. If present, these files are written to a separate temporary
9884 directory and GOPROXY is set to file://<proxy directory>.
@@ -309,11 +295,14 @@ parameter type pairs:
309295
310296Here is a complete example:
311297
298+ This test checks hovering over constants.
299+
312300 -- a.go --
313301 package a
314302
315303 const abc = 0x2a //@hover("b", "abc", abc),hover(" =", "abc", abc)
316- -- @abc/hover.md --
304+
305+ -- @abc --
317306 ```go
318307 const abc untyped int = 42
319308 ```
@@ -329,13 +318,13 @@ The first argument holds the test context, including fake editor with open
329318files, and sandboxed directory.
330319
331320Argument 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.)
339328
340329The next hover on the same line asserts the same result, but initiates the
341330hover immediately after "abc" in the source. This tests that we find the
0 commit comments