Skip to content

Commit 31fdda9

Browse files
liskinNsidorenco
andauthored
fix: "Couldn't find positions in path" (#48)
* fix: "Couldn't find positions in path" Quite often I get errors like this one: ERROR | 2025-10-18T18:40:14Z+0100 | ...te/pack/bundle/start/neotest/lua/neotest/client/init.lua:309 | Couldn't find positions in path <redacted> ...tart/neotest-vstest/lua/neotest-vstest/vstest/client.lua:44: Expected value but found unexpected end of string at character 292 stack traceback: [C]: in function 'decode' ...tart/neotest-vstest/lua/neotest-vstest/vstest/client.lua:44: in function 'discover_tests_in_project' .../start/neotest-vstest/lua/neotest-vstest/vstest/init.lua:34: in function 'discover_tests' ...undle/start/neotest-vstest/lua/neotest-vstest/client.lua:39: in function 'discover_tests' .../bundle/start/neotest-vstest/lua/neotest-vstest/init.lua:299: in function 'discover_positions' ...te/pack/bundle/start/neotest/lua/neotest/client/init.lua:300: in function <...te/pack/bundle/start/neotest/lua/neotest/client/init.lua:264> [C]: in function 'xpcall' ...te/pack/bundle/start/neotest/lua/neotest/client/init.lua:264: in function '_update_positions' ...te/pack/bundle/start/neotest/lua/neotest/client/init.lua:317: in function <...te/pack/bundle/start/neotest/lua/neotest/client/init.lua:315> I think that's because the test discovery doesn't flush the `outputFile` before signalling back by writing "1" to the `waitFile`. Using `using` to dispose of the `outputFile` `StreamWriter` seems to fix this — I don't get those errors any more. * replace using with do-use --------- Co-authored-by: nsidorenco <[email protected]>
1 parent 3ce4c18 commit 31fdda9

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

scripts/run_tests.fsx

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ module TestDiscovery =
110110
discoveredTests.TryAdd(testCase.Id, testCase) |> ignore)
111111

112112
member _.HandleDiscoveryComplete(_, _) =
113-
use testsWriter = new StreamWriter(outputFile, append = false)
114-
115113
let testFiles =
116114
discoveredTests.Values
117115
|> Seq.map (fun test -> test.CodeFilePath)
@@ -120,17 +118,20 @@ module TestDiscovery =
120118

121119
Console.WriteLine($"Discovered tests for: {testFiles}")
122120

123-
discoveredTests.Values
124-
|> Seq.sortBy (fun testCase -> testCase.CodeFilePath, testCase.LineNumber)
125-
|> Seq.map (fun testCase ->
126-
{ File = testCase.CodeFilePath
127-
Test =
128-
{ Id = testCase.Id
129-
CodeFilePath = testCase.CodeFilePath
130-
DisplayName = testCase.DisplayName
131-
LineNumber = testCase.LineNumber
132-
FullyQualifiedName = testCase.FullyQualifiedName } })
133-
|> Seq.iter (JsonConvert.SerializeObject >> testsWriter.WriteLine)
121+
do
122+
use testsWriter = new StreamWriter(outputFile, append = false)
123+
124+
discoveredTests.Values
125+
|> Seq.sortBy (fun testCase -> testCase.CodeFilePath, testCase.LineNumber)
126+
|> Seq.map (fun testCase ->
127+
{ File = testCase.CodeFilePath
128+
Test =
129+
{ Id = testCase.Id
130+
CodeFilePath = testCase.CodeFilePath
131+
DisplayName = testCase.DisplayName
132+
LineNumber = testCase.LineNumber
133+
FullyQualifiedName = testCase.FullyQualifiedName } })
134+
|> Seq.iter (JsonConvert.SerializeObject >> testsWriter.WriteLine)
134135

135136
use waitFileWriter = new StreamWriter(waitFile, append = false)
136137
waitFileWriter.WriteLine("1")
@@ -304,7 +305,12 @@ module TestDiscovery =
304305
let testCases = getTestCases args.Ids
305306

306307
use testHandler =
307-
new PlaygroundTestRunHandler(args.StreamPath, args.OutputPath, args.ProcessOutput, args.OutputDirPath)
308+
new PlaygroundTestRunHandler(
309+
args.StreamPath,
310+
args.OutputPath,
311+
args.ProcessOutput,
312+
args.OutputDirPath
313+
)
308314
// spawn as task to allow running concurrent tests
309315
do! r.RunTestsAsync(testCases, sourceSettings, testHandler)
310316
Console.WriteLine($"Done running tests for ids: ")
@@ -320,7 +326,12 @@ module TestDiscovery =
320326
let testCases = getTestCases args.Ids
321327

322328
use testHandler =
323-
new PlaygroundTestRunHandler(args.StreamPath, args.OutputPath, args.ProcessOutput, args.OutputDirPath)
329+
new PlaygroundTestRunHandler(
330+
args.StreamPath,
331+
args.OutputPath,
332+
args.ProcessOutput,
333+
args.OutputDirPath
334+
)
324335

325336
let debugLauncher = DebugLauncher(args.PidPath, args.AttachedPath)
326337
Console.WriteLine($"Starting {Seq.length testCases} tests in debug-mode")

0 commit comments

Comments
 (0)