Skip to content

Commit a37da74

Browse files
committed
Update docker-compose and improve test structure with new features
1 parent 0918bc1 commit a37da74

File tree

5 files changed

+292
-242
lines changed

5 files changed

+292
-242
lines changed

docker-compose.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ services:
22
seq:
33
profiles:
44
- seq
5-
image: datalust/seq
5+
image: datalust/seq:2024.3
66
ports:
77
- 5341:80 # http and collection
88
environment:
99
- ACCEPT_EULA=Y
1010
# http://localhost:5341
11-
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:5341/ingest/otlp/v1/logs
11+
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:5341/ingest/otlp/v1/traces
1212
# OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
1313
# OTEL_EXPORTER_OTLP_HEADERS="X-Seq-ApiKey=your_api_key"
1414
jaeger:
@@ -31,3 +31,16 @@ services:
3131
- COLLECTOR_OTLP_ENABLED=true
3232
# http://localhost:16686/
3333
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
34+
aspire:
35+
profiles:
36+
- aspire
37+
image: mcr.microsoft.com/dotnet/nightly/aspire-dashboard
38+
ports:
39+
- 4317:18889 #otel
40+
- 18888:18888 #http
41+
environment:
42+
- DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS=true
43+
# - OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
44+
# - OTEL_EXPORTER_OTLP_HEADERS=X-Seq-ApiKey=your_api_key
45+
# http://localhost:18888/
46+
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317

src/FsAutoComplete/LspServers/AdaptiveServerState.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,6 @@ type AdaptiveState
558558

559559
| _ -> ranges)
560560

561-
let! ct = Async.CancellationToken
562-
563561
return
564562
NotificationEvent.UnnecessaryParentheses(filePath, Array.ofSeq unnecessaryParentheses, file.Version)
565563
|> Some
@@ -2682,6 +2680,8 @@ type AdaptiveState
26822680

26832681
updateOpenFiles file
26842682

2683+
failwith "Something stupid happened"
2684+
26852685
do!
26862686
forceGetOpenFileTypeCheckResults filePath
26872687
|> Async.Ignore<Result<ParseAndCheckResults, string>>

test/FsAutoComplete.Tests.Lsp/CodeLensTests.fs

Lines changed: 160 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ open Helpers.Expecto.ShadowedTimeouts
1616
open System.IO
1717

1818
module private CodeLens =
19-
let examples = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "CodeLensProjectTests")
19+
let examples =
20+
Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "CodeLensProjectTests")
2021

2122
module CodeLensPositionStaysAccurate =
2223
let dir = examples </> "CodeLens_position_stays_accurate"
@@ -64,164 +65,181 @@ module private CodeLens =
6465

6566

6667
let projectBasedTests state =
67-
testList "ProjectBased" [
68-
serverTestList ("CodeLensPositionStaysAccurate") state defaultConfigDto (Some CodeLens.CodeLensPositionStaysAccurate.dir) (fun server -> [
69-
70-
testCaseAsync "can show codelens after adding newlines to code"
71-
<| (asyncResult {
72-
let program = CodeLens.CodeLensPositionStaysAccurate.programFile
73-
let! (doc, _diags) = Server.openDocument program server
74-
75-
let! unresolved = CodeLens.getLenses doc
76-
let! resolved = CodeLens.getResolvedLenses doc unresolved
77-
78-
let references =
79-
resolved
80-
|> List.filter (fun lens -> lens.Command |>Option.exists (fun c -> c.Title.EndsWith "References"))
81-
|> List.sortBy (fun lens -> lens.Range.Start.Line)
82-
83-
Expect.hasLength references 2 "should have a reference lens"
84-
85-
let lens1 = references.[0]
86-
let lens1Range : Range = {
87-
Start = { Line = 1u; Character = 6u }
88-
End = { Line = 1u; Character = 20u }
89-
}
90-
91-
Expect.equal lens1.Range lens1Range "Lens 1 should be at 1:6-1:20"
92-
93-
let lens2 = references.[1]
94-
let lens2Range : Range = {
95-
Start = { Line = 3u; Character = 6u }
96-
End = { Line = 3u; Character = 25u }
97-
}
98-
99-
Expect.equal lens2.Range lens2Range "Lens 2 should be at 3:6-3:25"
100-
101-
do! doc.Server.Server.TextDocumentDidChange({
102-
TextDocument = doc.VersionedTextDocumentIdentifier
103-
ContentChanges = [| U2.C1 {
104-
Range = { Start = { Line = 2u; Character = 0u }; End = { Line = 2u; Character = 0u }; }
105-
RangeLength = None
106-
Text = "\n\n"
107-
} |]
108-
})
68+
testList
69+
"ProjectBased"
70+
[ serverTestList
71+
("CodeLensPositionStaysAccurate")
72+
state
73+
defaultConfigDto
74+
(Some CodeLens.CodeLensPositionStaysAccurate.dir)
75+
(fun server ->
76+
[
77+
78+
testCaseAsync "can show codelens after adding newlines to code"
79+
<| (asyncResult {
80+
let program = CodeLens.CodeLensPositionStaysAccurate.programFile
81+
let! (doc, _diags) = Server.openDocument program server
82+
83+
let! unresolved = CodeLens.getLenses doc
84+
let! resolved = CodeLens.getResolvedLenses doc unresolved
85+
86+
let references =
87+
resolved
88+
|> List.filter (fun lens -> lens.Command |> Option.exists (fun c -> c.Title.EndsWith "References"))
89+
|> List.sortBy (fun lens -> lens.Range.Start.Line)
90+
91+
Expect.hasLength references 2 "should have a reference lens"
92+
93+
let lens1 = references.[0]
94+
95+
let lens1Range: Range =
96+
{ Start = { Line = 1u; Character = 6u }
97+
End = { Line = 1u; Character = 20u } }
98+
99+
Expect.equal lens1.Range lens1Range "Lens 1 should be at 1:6-1:20"
100+
101+
let lens2 = references.[1]
109102

110-
let! nextLens = CodeLens.getLenses doc
111-
let! resolvedNextLens = CodeLens.getResolvedLenses doc nextLens
103+
let lens2Range: Range =
104+
{ Start = { Line = 3u; Character = 6u }
105+
End = { Line = 3u; Character = 25u } }
112106

113-
let references =
114-
resolvedNextLens
115-
|> List.filter (fun lens -> lens.Command |>Option.exists (fun c -> c.Title.EndsWith "References"))
116-
|> List.sortBy (fun lens -> lens.Range.Start.Line)
107+
Expect.equal lens2.Range lens2Range "Lens 2 should be at 3:6-3:25"
117108

118-
let lens1 = references.[0]
119-
let lens1Range : Range = {
120-
Start = { Line = 1u; Character = 6u }
121-
End = { Line = 1u; Character = 20u }
122-
}
109+
do!
110+
doc.Server.Server.TextDocumentDidChange(
111+
{ TextDocument = doc.VersionedTextDocumentIdentifier
112+
ContentChanges =
113+
[| U2.C1
114+
{ Range =
115+
{ Start = { Line = 2u; Character = 0u }
116+
End = { Line = 2u; Character = 0u } }
117+
RangeLength = None
118+
Text = "\n\n" } |] }
119+
)
123120

124-
Expect.equal lens1.Range lens1Range "Lens 1 should be at 1:6-1:20"
121+
let! nextLens = CodeLens.getLenses doc
122+
let! resolvedNextLens = CodeLens.getResolvedLenses doc nextLens
125123

126-
let lens2 = references.[1]
127-
let lens2Range : Range = {
128-
Start = { Line = 5u; Character = 6u }
129-
End = { Line = 5u; Character = 25u }
130-
}
124+
let references =
125+
resolvedNextLens
126+
|> List.filter (fun lens -> lens.Command |> Option.exists (fun c -> c.Title.EndsWith "References"))
127+
|> List.sortBy (fun lens -> lens.Range.Start.Line)
131128

132-
Expect.equal lens2.Range lens2Range "Lens 2 should be at 5:6-5:25"
129+
let lens1 = references.[0]
133130

134-
return ()
135-
}
136-
|> AsyncResult.foldResult id (fun e -> failtest $"{e}" ))
131+
let lens1Range: Range =
132+
{ Start = { Line = 1u; Character = 6u }
133+
End = { Line = 1u; Character = 20u } }
137134

138-
]
139-
)
140-
]
135+
Expect.equal lens1.Range lens1Range "Lens 1 should be at 1:6-1:20"
136+
137+
let lens2 = references.[1]
138+
139+
let lens2Range: Range =
140+
{ Start = { Line = 5u; Character = 6u }
141+
End = { Line = 5u; Character = 25u } }
142+
143+
Expect.equal lens2.Range lens2Range "Lens 2 should be at 5:6-5:25"
144+
145+
return ()
146+
}
147+
|> AsyncResult.foldResult id (fun e -> failtest $"{e}"))
148+
149+
]) ]
141150

142151
let tests state =
143152

144-
testList (nameof CodeLens) [
145-
projectBasedTests state
146-
serverTestList "scriptTests" state defaultConfigDto None (fun server ->
147-
[ testCaseAsync "can show codelens for type annotation"
148-
<| CodeLens.check server """
153+
testList
154+
(nameof CodeLens)
155+
[ projectBasedTests state
156+
serverTestList "scriptTests" state defaultConfigDto None (fun server ->
157+
[ testCaseAsync "can show codelens for type annotation"
158+
<| CodeLens.check server """
149159
module X =
150160
$0let func x = x + 1$0
151-
""" (fun (_doc, lenses, _unresolved, _resolved) -> async {
152-
Expect.hasLength lenses 2 "should have a type lens and a reference lens"
153-
let typeLens = lenses[0]
154-
Expect.equal typeLens.Command.Value.Title "int -> int" "first lens should be a type hint of int to int"
155-
Expect.isNone typeLens.Command.Value.Arguments "No data required for type lenses"
156-
Expect.equal typeLens.Command.Value.Command "" "No command for type lenses" })
157-
158-
testCaseAsync "can show codelens for 0 reference count"
159-
<| CodeLens.check server """
161+
""" (fun (_doc, lenses, _unresolved, _resolved) ->
162+
async {
163+
Expect.hasLength lenses 2 "should have a type lens and a reference lens"
164+
let typeLens = lenses[0]
165+
Expect.equal typeLens.Command.Value.Title "int -> int" "first lens should be a type hint of int to int"
166+
Expect.isNone typeLens.Command.Value.Arguments "No data required for type lenses"
167+
Expect.equal typeLens.Command.Value.Command "" "No command for type lenses"
168+
})
169+
170+
testCaseAsync "can show codelens for 0 reference count"
171+
<| CodeLens.check server """
160172
module X =
161173
$0let func x = x + 1$0
162-
""" (fun (_doc, lenses, _unresolved, _resolved) -> async {
163-
Expect.hasLength lenses 2 "should have a type lens and a reference lens"
164-
let referenceLens = lenses[1]
165-
166-
let emptyCommand =
167-
Some
168-
{ Title = "0 References"
169-
Arguments = None
170-
Command = "" }
171-
172-
Expect.equal referenceLens.Command emptyCommand "There should be no command or args for zero references" })
173-
testCaseAsync "can show codelens for multi reference count"
174-
<| CodeLens.check server """
174+
""" (fun (_doc, lenses, _unresolved, _resolved) ->
175+
async {
176+
Expect.hasLength lenses 2 "should have a type lens and a reference lens"
177+
let referenceLens = lenses[1]
178+
179+
let emptyCommand =
180+
Some
181+
{ Title = "0 References"
182+
Arguments = None
183+
Command = "" }
184+
185+
Expect.equal referenceLens.Command emptyCommand "There should be no command or args for zero references"
186+
})
187+
testCaseAsync "can show codelens for multi reference count"
188+
<| CodeLens.check server """
175189
module X =
176190
$0let func x = x + 1$0
177191
178192
let doThing () = func 1
179-
""" (fun (doc, lenses, _unresolved, _resolved) -> async {
180-
181-
182-
Expect.hasLength lenses 2 "should have a type lens and a reference lens"
183-
let referenceLens = lenses[1]
184-
Expect.isSome referenceLens.Command "There should be a command for multiple references"
185-
let referenceCommand = referenceLens.Command.Value
186-
Expect.equal referenceCommand.Title "1 References" "There should be a title for multiple references"
187-
188-
Expect.equal
189-
referenceCommand.Command
190-
"fsharp.showReferences"
191-
"There should be a command for multiple references"
192-
193-
Expect.isSome referenceCommand.Arguments "There should be arguments for multiple references"
194-
let args = referenceCommand.Arguments.Value
195-
Expect.equal args.Length 3 "There should be 2 args"
196-
197-
let filePath, triggerPos, referenceRanges =
198-
args[0].Value<string>(),
199-
(args[1] :?> JObject).ToObject<Ionide.LanguageServerProtocol.Types.Position>(),
200-
(args[2] :?> JArray)
201-
|> Seq.map (fun t -> (t :?> JObject).ToObject<Ionide.LanguageServerProtocol.Types.Location>())
202-
|> Array.ofSeq
203-
204-
Expect.equal filePath doc.Uri "File path should be the doc we're checking"
205-
Expect.equal triggerPos { Line = 1u; Character = 6u } "Position should be 1:6"
206-
Expect.hasLength referenceRanges 1 "There should be 1 reference range for the `func` function"
207-
208-
Expect.equal
209-
referenceRanges[0]
210-
{ Uri = doc.Uri
211-
Range =
212-
{ Start = { Line = 3u; Character = 19u }
213-
End = { Line = 3u; Character = 23u } } }
214-
"Reference range should be 0:0"})
215-
testCaseAsync "can show reference counts for 1-character identifier"
216-
<| CodeLens.check server """
193+
""" (fun (doc, lenses, _unresolved, _resolved) ->
194+
async {
195+
196+
197+
Expect.hasLength lenses 2 "should have a type lens and a reference lens"
198+
let referenceLens = lenses[1]
199+
Expect.isSome referenceLens.Command "There should be a command for multiple references"
200+
let referenceCommand = referenceLens.Command.Value
201+
Expect.equal referenceCommand.Title "1 References" "There should be a title for multiple references"
202+
203+
Expect.equal
204+
referenceCommand.Command
205+
"fsharp.showReferences"
206+
"There should be a command for multiple references"
207+
208+
Expect.isSome referenceCommand.Arguments "There should be arguments for multiple references"
209+
let args = referenceCommand.Arguments.Value
210+
Expect.equal args.Length 3 "There should be 2 args"
211+
212+
let filePath, triggerPos, referenceRanges =
213+
args[0].Value<string>(),
214+
(args[1] :?> JObject).ToObject<Ionide.LanguageServerProtocol.Types.Position>(),
215+
(args[2] :?> JArray)
216+
|> Seq.map (fun t -> (t :?> JObject).ToObject<Ionide.LanguageServerProtocol.Types.Location>())
217+
|> Array.ofSeq
218+
219+
Expect.equal filePath doc.Uri "File path should be the doc we're checking"
220+
Expect.equal triggerPos { Line = 1u; Character = 6u } "Position should be 1:6"
221+
Expect.hasLength referenceRanges 1 "There should be 1 reference range for the `func` function"
222+
223+
Expect.equal
224+
referenceRanges[0]
225+
{ Uri = doc.Uri
226+
Range =
227+
{ Start = { Line = 3u; Character = 19u }
228+
End = { Line = 3u; Character = 23u } } }
229+
"Reference range should be 0:0"
230+
})
231+
testCaseAsync "can show reference counts for 1-character identifier"
232+
<| CodeLens.check server """
217233
$0let f () = ""$0
218-
""" (fun (_doc, lenses, _unresolved, _resolved) -> async {
219-
Expect.hasLength lenses 2 "should have a type lens and a reference lens"
220-
let referenceLens = lenses[1]
221-
Expect.isSome referenceLens.Command "There should be a command for multiple references"
222-
let referenceCommand = referenceLens.Command.Value
223-
Expect.equal referenceCommand.Title "0 References" "There should be a title for multiple references"
224-
Expect.equal referenceCommand.Command "" "There should be no command for multiple references"
225-
Expect.isNone referenceCommand.Arguments "There should be arguments for multiple references"}) ])
226-
227-
]
234+
""" (fun (_doc, lenses, _unresolved, _resolved) ->
235+
async {
236+
Expect.hasLength lenses 2 "should have a type lens and a reference lens"
237+
let referenceLens = lenses[1]
238+
Expect.isSome referenceLens.Command "There should be a command for multiple references"
239+
let referenceCommand = referenceLens.Command.Value
240+
Expect.equal referenceCommand.Title "0 References" "There should be a title for multiple references"
241+
Expect.equal referenceCommand.Command "" "There should be no command for multiple references"
242+
Expect.isNone referenceCommand.Arguments "There should be arguments for multiple references"
243+
}) ])
244+
245+
]

0 commit comments

Comments
 (0)