This commit is contained in:
@@ -134,6 +134,17 @@ local function to_jest_full_name(name)
|
|||||||
return table.concat(parts, " ")
|
return table.concat(parts, " ")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function last_segment(name)
|
||||||
|
if not name or name == "" then
|
||||||
|
return name
|
||||||
|
end
|
||||||
|
if not name:find("/", 1, true) then
|
||||||
|
return name
|
||||||
|
end
|
||||||
|
local parts = vim.split(name, "/", { plain = true, trimempty = true })
|
||||||
|
return parts[#parts] or name
|
||||||
|
end
|
||||||
|
|
||||||
local function find_tests(lines)
|
local function find_tests(lines)
|
||||||
local tests = {}
|
local tests = {}
|
||||||
local describes = {}
|
local describes = {}
|
||||||
@@ -493,8 +504,8 @@ function runner.build_failed_command(last_command, failures, _scope_kind)
|
|||||||
local pattern_parts = {}
|
local pattern_parts = {}
|
||||||
for _, name in ipairs(failures or {}) do
|
for _, name in ipairs(failures or {}) do
|
||||||
if name and name ~= "" then
|
if name and name ~= "" then
|
||||||
local jest_name = runner._last_jest_names[name] or to_jest_full_name(name)
|
local title = last_segment(name)
|
||||||
table.insert(pattern_parts, "^" .. escape_regex(jest_name) .. "$")
|
table.insert(pattern_parts, "^.*" .. escape_regex(title) .. "$")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local pattern = "(" .. table.concat(pattern_parts, "|") .. ")"
|
local pattern = "(" .. table.concat(pattern_parts, "|") .. ")"
|
||||||
@@ -599,11 +610,11 @@ function runner.output_parser()
|
|||||||
state.jest.failures_seen[data.name] = true
|
state.jest.failures_seen[data.name] = true
|
||||||
table.insert(state.jest.failures_all, data.name)
|
table.insert(state.jest.failures_all, data.name)
|
||||||
end
|
end
|
||||||
results.failures_all = vim.deepcopy(state.jest.failures_all)
|
|
||||||
else
|
else
|
||||||
results.skips = { data.name }
|
results.skips = { data.name }
|
||||||
results.display.skips = { data.display or data.name }
|
results.display.skips = { data.display or data.name }
|
||||||
end
|
end
|
||||||
|
results.failures_all = vim.deepcopy(state.jest.failures_all)
|
||||||
update_location_cache(data.name, data)
|
update_location_cache(data.name, data)
|
||||||
return results
|
return results
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -287,18 +287,6 @@ describe("test-samurai-jest-runner", function()
|
|||||||
cwd = "/tmp",
|
cwd = "/tmp",
|
||||||
}
|
}
|
||||||
local failures = { "Math/adds", "edge (1+1)" }
|
local failures = { "Math/adds", "edge (1+1)" }
|
||||||
runner.parse_results(table.concat({
|
|
||||||
"TSAMURAI_RESULT " .. vim.json.encode({
|
|
||||||
name = "Math/adds",
|
|
||||||
jestName = "Math adds",
|
|
||||||
status = "failed",
|
|
||||||
}),
|
|
||||||
"TSAMURAI_RESULT " .. vim.json.encode({
|
|
||||||
name = "edge (1+1)",
|
|
||||||
jestName = "edge (1+1)",
|
|
||||||
status = "failed",
|
|
||||||
}),
|
|
||||||
}, "\n"))
|
|
||||||
|
|
||||||
local cmd_spec = runner.build_failed_command(last_command, failures, "file")
|
local cmd_spec = runner.build_failed_command(last_command, failures, "file")
|
||||||
|
|
||||||
@@ -317,7 +305,7 @@ describe("test-samurai-jest-runner", function()
|
|||||||
},
|
},
|
||||||
cmd_spec.cmd
|
cmd_spec.cmd
|
||||||
)
|
)
|
||||||
assert.is_true(pattern:match("%^Math adds%$") ~= nil)
|
assert.is_true(pattern:match("%^%..*adds%$") ~= nil)
|
||||||
assert.is_true(pattern:match("edge") ~= nil)
|
assert.is_true(pattern:match("edge") ~= nil)
|
||||||
assert.is_true(pattern:find("\\(1", 1, true) ~= nil)
|
assert.is_true(pattern:find("\\(1", 1, true) ~= nil)
|
||||||
assert.is_true(pattern:find("\\+1", 1, true) ~= nil)
|
assert.is_true(pattern:find("\\+1", 1, true) ~= nil)
|
||||||
@@ -373,6 +361,24 @@ describe("test-samurai-jest-runner", function()
|
|||||||
assert.is_nil(parser.on_complete("", state))
|
assert.is_nil(parser.on_complete("", state))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("keeps failures_all across non-failure lines", function()
|
||||||
|
local parser = runner.output_parser()
|
||||||
|
local state = {}
|
||||||
|
local fail_line = "TSAMURAI_RESULT " .. vim.json.encode({
|
||||||
|
name = "Math/adds",
|
||||||
|
status = "failed",
|
||||||
|
})
|
||||||
|
local pass_line = "TSAMURAI_RESULT " .. vim.json.encode({
|
||||||
|
name = "Math/other",
|
||||||
|
status = "passed",
|
||||||
|
})
|
||||||
|
|
||||||
|
parser.on_line(fail_line, state)
|
||||||
|
local results = parser.on_line(pass_line, state)
|
||||||
|
|
||||||
|
assert.are.same({ "Math/adds" }, results.failures_all)
|
||||||
|
end)
|
||||||
|
|
||||||
it("parse_test_output groups output per test", function()
|
it("parse_test_output groups output per test", function()
|
||||||
local output = table.concat({
|
local output = table.concat({
|
||||||
"TSAMURAI_RESULT " .. vim.json.encode({
|
"TSAMURAI_RESULT " .. vim.json.encode({
|
||||||
|
|||||||
Reference in New Issue
Block a user