Skip to content

Commit

Permalink
handle running directories
Browse files Browse the repository at this point in the history
  • Loading branch information
Nsidorenco committed Nov 14, 2024
1 parent c257060 commit 708ff2c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
26 changes: 14 additions & 12 deletions lua/neotest-dotnet/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,22 @@ DotnetNeotestAdapter.build_spec = function(args)

local pos = args.tree:data()

local ids = {}

if pos.type ~= "test" then
return
ids = {}
for _, position in tree:iter() do
if position.type == "test" then
ids[#ids + 1] = position.id
end
end
else
ids = { pos.id }
end

logger.debug("ids:")
logger.debug(ids)

local results_path = nio.fn.tempname()
local stream_path = nio.fn.tempname()
lib.files.write(results_path, "")
Expand Down Expand Up @@ -189,12 +201,10 @@ DotnetNeotestAdapter.build_spec = function(args)
end

return {
command = vstest.run_tests(pos.id, stream_path, results_path),
command = vstest.run_tests(ids, stream_path, results_path),
context = {
result_path = results_path,
stop_stream = stop_stream,
file = pos.path,
id = pos.id,
},
stream = function()
return function()
Expand All @@ -220,14 +230,6 @@ DotnetNeotestAdapter.results = function(spec)
local results = {}

if not success then
local outcome = "skipped"
results[spec.context.id] = {
status = outcome,
errors = {
message = "failed to read result file: " .. data,
},
}

return results
end

Expand Down
12 changes: 8 additions & 4 deletions run_tests.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ open Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces

module TestDiscovery =
open System.Collections.Concurrent
open System.Collections.Concurrent

[<return: Struct>]
let (|DiscoveryRequest|_|) (str: string) =
Expand Down Expand Up @@ -85,11 +86,14 @@ module TestDiscovery =
member __.HandleRawMessage(_) = ()

type PlaygroundTestRunHandler(streamOutputPath, outputFilePath) =
let resultsDictionary = ConcurrentDictionary()

interface ITestRunEventsHandler with
member _.HandleTestRunComplete
(_testRunCompleteArgs, _lastChunkArgs, _runContextAttachments, _executorUris)
=
()
use outputWriter = new StreamWriter(outputFilePath, append = false)
outputWriter.WriteLine(JsonConvert.SerializeObject(resultsDictionary))

member __.HandleLogMessage(_level, _message) = ()

Expand Down Expand Up @@ -130,16 +134,16 @@ module TestDiscovery =
short = $"{result.TestCase.DisplayName}:{outcome}"
errors = errors |})

for (id, result) in results do
resultsDictionary.AddOrUpdate(id, result, (fun _ _ -> result)) |> ignore

use streamWriter = new StreamWriter(streamOutputPath, append = true)

for (id, result) in results do
{| id = id; result = result |}
|> JsonConvert.SerializeObject
|> streamWriter.WriteLine

use outputWriter = new StreamWriter(outputFilePath, append = false)
outputWriter.WriteLine(JsonConvert.SerializeObject(Map.ofSeq results))

member __.LaunchProcessWithDebuggerAttached(_testProcessStartInfo) = 1

type DebugLauncher(pidFile: string, attachedFile: string) =
Expand Down

0 comments on commit 708ff2c

Please sign in to comment.