Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: passed test output massage and tmp folder #6

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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