From 194b1481a77a696d2a45eb4ef5a1fe462df6ba7b Mon Sep 17 00:00:00 2001 From: Igor Date: Mon, 4 Dec 2023 17:48:17 -0300 Subject: [PATCH] fix(errors): handle latest nextest diagnostics --- lua/neotest-rust/errors.lua | 2 +- tests/data/simple-package/multiple_test_suites.xml | 12 ++++++++---- tests/data/simple-package/single_test_suite.xml | 6 ++++-- tests/errors_spec.lua | 10 ++++------ tests/init_spec.lua | 12 ++++++------ 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/lua/neotest-rust/errors.lua b/lua/neotest-rust/errors.lua index 69bc1ea..a4524ec 100644 --- a/lua/neotest-rust/errors.lua +++ b/lua/neotest-rust/errors.lua @@ -8,7 +8,7 @@ function M.parse_errors(output) return {} end - local message, line = output:match("thread '[^']+' panicked at '([^']+)', [^:]+:(%d+):%d+") + local line, message = output:match("thread '[^']+' panicked at [^:]+:(%d+):%d+:\n(.*)note:.*") -- If we can't parse the output, return an empty table if message == nil then diff --git a/tests/data/simple-package/multiple_test_suites.xml b/tests/data/simple-package/multiple_test_suites.xml index 806711d..ba75b38 100644 --- a/tests/data/simple-package/multiple_test_suites.xml +++ b/tests/data/simple-package/multiple_test_suites.xml @@ -2,7 +2,8 @@ - thread 'foo::tests::should_fail' panicked at 'assertion failed: false', src/foo.rs:10:9 + thread 'foo::tests::should_fail' panicked at src/foo.rs:10:9: +assertion failed: false note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace running 1 test @@ -16,7 +17,8 @@ failures: test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.00s - thread 'foo::tests::should_fail' panicked at 'assertion failed: false', src/foo.rs:10:9 + thread 'foo::tests::should_fail' panicked at src/foo.rs:10:9: +assertion failed: false note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace @@ -25,7 +27,8 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace - thread 'should_fail' panicked at 'assertion failed: false', tests/tests.rs:8:5 + thread 'should_fail' panicked at tests/tests.rs:8:5: +assertion failed: false note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace running 1 test @@ -39,7 +42,8 @@ failures: test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.00s - thread 'should_fail' panicked at 'assertion failed: false', tests/tests.rs:8:5 + thread 'should_fail' panicked at tests/tests.rs:8:5 +assertion failed: false note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/data/simple-package/single_test_suite.xml b/tests/data/simple-package/single_test_suite.xml index a8a781a..d026f4d 100644 --- a/tests/data/simple-package/single_test_suite.xml +++ b/tests/data/simple-package/single_test_suite.xml @@ -4,7 +4,8 @@ - thread 'foo::tests::should_fail' panicked at 'assertion failed: false', src/foo.rs:10:9 + thread 'foo::tests::should_fail' panicked at src/foo.rs:10:9: +assertion failed: false note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace running 1 test @@ -18,7 +19,8 @@ failures: test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.00s - thread 'foo::tests::should_fail' panicked at 'assertion failed: false', src/foo.rs:10:9 + thread 'foo::tests::should_fail' panicked at src/foo.rs:10:9: +assertion failed: false note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/errors_spec.lua b/tests/errors_spec.lua index b781f51..7704a3b 100644 --- a/tests/errors_spec.lua +++ b/tests/errors_spec.lua @@ -9,19 +9,17 @@ describe("parses errors from output", function() end) it("assert_eq", function() - local output = "test tests::failed_math ... FAILED\n" - .. "failures:\n\n" - .. "---- tests::failed_math stdout ----\n" - .. "thread 'tests::failed_math' panicked at 'assertion failed: `(left == right)`\n" + local output = "thread 'tests::failed_math' panicked at src/main.rs:16:9:\n" + .. "assertion `left == right` failed\n" .. " left: `2`,\n" - .. " right: `3`', src/main.rs:16:9\n" + .. " right: `3`\n" .. "note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace" local results = errors.parse_errors(output) local expected = { { line = 15, - message = "assertion failed: `(left == right)`\n left: `2`,\n right: `3`", + message = "assertion `left == right` failed\n left: `2`,\n right: `3`\n", }, } diff --git a/tests/init_spec.lua b/tests/init_spec.lua index a6c35a6..19f9fd1 100644 --- a/tests/init_spec.lua +++ b/tests/init_spec.lua @@ -982,12 +982,12 @@ describe("results", function() local expected = { ["foo::tests::should_fail"] = { - short = "thread 'foo::tests::should_fail' panicked at 'assertion failed: false', src/foo.rs:10:9\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace", + short = "thread 'foo::tests::should_fail' panicked at src/foo.rs:10:9:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace", status = "failed", errors = { { line = 9, - message = "assertion failed: false", + message = "assertion failed: false\n", }, }, }, @@ -1040,17 +1040,17 @@ describe("results", function() local expected = { ["foo::tests::should_fail"] = { - short = "thread 'foo::tests::should_fail' panicked at 'assertion failed: false', src/foo.rs:10:9\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace", + short = "thread 'foo::tests::should_fail' panicked at src/foo.rs:10:9:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace", status = "failed", - errors = { { line = 9, message = "assertion failed: false" } }, + errors = { { line = 9, message = "assertion failed: false\n" } }, }, ["foo::tests::should_pass"] = { status = "passed", }, should_fail = { - short = "thread 'should_fail' panicked at 'assertion failed: false', tests/tests.rs:8:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace", + short = "thread 'should_fail' panicked at tests/tests.rs:8:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace", status = "failed", - errors = { { line = 7, message = "assertion failed: false" } }, + errors = { { line = 7, message = "assertion failed: false\n" } }, }, should_pass = { status = "passed",