Skip to content

Commit

Permalink
fix: passed test output massage and tmp folder
Browse files Browse the repository at this point in the history
  • Loading branch information
atm1020 committed Nov 30, 2024
1 parent 06562c9 commit 95cf827
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lua/neotest-jdtls/neotest/impl/results.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ local project = require('neotest-jdtls.utils.project')
local jdtls = require('neotest-jdtls.utils.jdtls')
local nio = require('nio')

local default_passed_test_output =
'The console output is available in the DAP console.'
---@type string|nil
local default_passed_test_output_path = nil

local M = {}

--- @enum TestStatus
Expand All @@ -14,6 +19,14 @@ local TestStatus = {
Passed = 'passed',
}

local function get_default_passed_test_output_path()
if not default_passed_test_output_path then
default_passed_test_output_path = async.fn.tempname()
lib.files.write(default_passed_test_output_path, default_passed_test_output)
end
return default_passed_test_output_path
end

local function get_short_error_message(result)
if result.actual and result.expected then
return string.format(
Expand Down Expand Up @@ -50,12 +63,14 @@ local function map_to_neotest_result_item(item)
status = TestStatus.Skipped,
}
else
local results_path = async.fn.tempname()
local results_path
local log_data
if item.result.trace then
log_data = table.concat(item.result.trace, '\n')
results_path = async.fn.tempname()
else
log_data = 'Test passed (There is no output available)'
log_data = default_passed_test_output
results_path = get_default_passed_test_output_path()
end
lib.files.write(results_path, log_data)
return {
Expand Down Expand Up @@ -124,6 +139,7 @@ local function merge_neotest_results(test_result_lookup, node_data)

local dynamic_test_result = {
status = TestStatus.Passed,
output = get_default_passed_test_output_path(),
}
for _, result in ipairs(test_result_lookup[key]) do
-- TODO merge stack traces
Expand All @@ -142,6 +158,7 @@ end
---@param tree neotest.Tree
function M.results(spec, _, tree)
log.debug('Parsing test results', vim.inspect(spec.context.report))
default_passed_test_output_path = nil
--- Set the results to skipped if the report is not available
if not spec.context.report then
local results = {}
Expand Down

0 comments on commit 95cf827

Please sign in to comment.