noib3 / nvim-oxi

:link: Rust bindings to all things Neovim
https://crates.io/crates/nvim-oxi
MIT License
878 stars 43 forks source link

Improve the output of the `test` macro. #162

Closed noib3 closed 4 months ago

noib3 commented 4 months ago

Improves the output message when the test fails.

#[oxi::test]
fn foo() {
    panic!();
}

#[oxi::test]
fn bar() -> Result<(), String> {
    Err("bar".into())
}

Before:

---- api::autocmd::foo stdout ----
thread 'api::autocmd::foo' panicked at src/api/autocmd.rs:5:1:
src/api/autocmd.rs:7:5:
explicit panic
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- api::autocmd::bar stdout ----
thread 'api::autocmd::bar' panicked at src/api/autocmd.rs:10:1:
"bar"

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

After:

---- api::autocmd::foo stdout ----
thread '<unnamed>' panicked at src/api/autocmd.rs:7:5:
explicit panic

---- api::autocmd::bar stdout ----
Error: "bar"