Skip to content

Commit

Permalink
Merge pull request #70 from mrcjkb/tokio-test-expression
Browse files Browse the repository at this point in the history
parse unexpected panics
  • Loading branch information
rouge8 committed Jan 25, 2024
2 parents 3a3ebe6 + 26ccc77 commit d945ccc
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lua/neotest-rust/errors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ function M.parse_errors(output)

local message, line = output:match("thread '[^']+' panicked at '([^']+)', [^:]+:(%d+):%d+")

if message == nil then
-- Try a different expression
_, line, message = output:match("thread '[^']+' panicked at ([^:]+):(%d+):[^:]+:\n([^\n]*)")
end

-- If we can't parse the output, return an empty table
if message == nil then
return {}
Expand Down
33 changes: 33 additions & 0 deletions tests/errors_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,37 @@ describe("parses errors from output", function()

assert.are.same(expected, results)
end)

it("parses unexpected panics", function()
local output = [[
running 1 test
test rocks::dependency::tests::parse_dependency ... FAILED
failures:
Finished test [unoptimized + debuginfo] target(s) in 0.12s
Starting 1 test across 2 binaries (17 skipped)
FAIL [ 0.004s] rocks-lib rocks::dependency::tests::parse_dependency
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 17 filtered out; finis
hed in 0.00s
--- STDERR: rocks-lib rocks::dependency::tests::parse_dependency ---
thread 'rocks::dependency::tests::parse_dependency' panicked at rocks-lib/src/rocks/dependency.rs:86:64:
called `Result::unwrap()` on an `Err` value: unexpected end of input while parsing min or version number
Location:
rocks-lib/src/rocks/dependency.rs:62:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
]]
local results = errors.parse_errors(output)
local expected = {
{
line = 85,
message = "called `Result::unwrap()` on an `Err` value: unexpected end of input while parsing min or version number",
},
}

assert.are.same(expected, results)
end)
end)

0 comments on commit d945ccc

Please sign in to comment.