@@ -284,22 +284,23 @@ local function get_cwd(file_path)
284
284
end
285
285
286
286
local function parsed_json_to_results (data , output_file , consoleOut )
287
+ local function parsed_json_to_results (data , output_file , console_out )
287
288
local tests = {}
288
289
289
- for _ , testResult in pairs (data .testResults ) do
290
- local testFn = testResult .name
290
+ for _ , test_result in pairs (data .testResults ) do
291
+ local test_file = test_result .name
291
292
292
- for _ , assertionResult in pairs (testResult .assertionResults ) do
293
- local status , name = assertionResult .status , assertionResult .title
293
+ for _ , assertion_result in pairs (test_result .assertionResults ) do
294
+ local status , name = assertion_result .status , assertion_result .title
294
295
295
296
if name == nil then
296
- logger .error (" Failed to find parsed test result " , assertionResult )
297
+ logger .error (" Failed to find parsed test result " , assertion_result )
297
298
return {}
298
299
end
299
300
300
- local keyid = testFn
301
+ local keyid = test_file
301
302
302
- for _ , value in ipairs (assertionResult .ancestorTitles ) do
303
+ for _ , value in ipairs (assertion_result .ancestorTitles ) do
303
304
if value ~= " " then
304
305
keyid = keyid .. " ::" .. value
305
306
end
@@ -314,19 +315,19 @@ local function parsed_json_to_results(data, output_file, consoleOut)
314
315
tests [keyid ] = {
315
316
status = status ,
316
317
short = name .. " : " .. status ,
317
- output = consoleOut ,
318
- location = assertionResult .location ,
318
+ output = console_out ,
319
+ location = assertion_result .location ,
319
320
}
320
321
321
- if not vim .tbl_isempty (assertionResult .failureMessages ) then
322
+ if not vim .tbl_isempty (assertion_result .failureMessages ) then
322
323
local errors = {}
323
324
324
- for i , failMessage in ipairs (assertionResult .failureMessages ) do
325
- local msg = clean_ansi (failMessage )
325
+ for i , fail_message in ipairs (assertion_result .failureMessages ) do
326
+ local msg = clean_ansi (fail_message )
326
327
327
328
errors [i ] = {
328
- line = (assertionResult .location and assertionResult .location .line - 1 or nil ),
329
- column = (assertionResult .location and assertionResult .location .column or nil ),
329
+ line = (assertion_result .location and assertion_result .location .line - 1 or nil ),
330
+ column = (assertion_result .location and assertion_result .location .column or nil ),
330
331
message = msg ,
331
332
}
332
333
425
426
function adapter .results (spec , b , tree )
426
427
spec .context .stop_stream ()
427
428
428
- local output_file = spec .context .results_path
429
- local success , data = pcall (lib .files .read , output_file )
430
-
431
- if not success then
432
- logger .error (" No test output file found " , output_file )
433
- return {}
434
- end
435
-
436
- local ok , parsed = pcall (vim .json .decode , data , { luanil = { object = true } })
437
- if not ok then
438
- logger .error (" Failed to parse test output json " , output_file )
439
- return {}
440
- end
441
-
442
- local results = parsed_json_to_results (parsed , output_file , b .output )
443
- return results
444
- end
445
-
446
- --- @async
447
- --- @param spec neotest.RunSpec
448
- --- @return neotest.Result[]
449
- function adapter .results (spec , b , tree )
450
429
local output_file = spec .context .results_path
451
430
452
431
local success , data = pcall (lib .files .read , output_file )
0 commit comments