nextest-rs / nextest

A next-generation test runner for Rust.
https://nexte.st
Apache License 2.0
2.17k stars 96 forks source link

`libtest-mimic` test failure not recognised #836

Closed niluxv closed 6 months ago

niluxv commented 1 year ago

I'm using a custom test harness using libtest-mimic (version 0.6.0), but when one of those tests fails, cargo nextest run still reports it as passed.

sunshowers commented 1 year ago

Hi there, thanks for the report! I don't seem to be able to reproduce this issue with datatest-stable, with:

Could you provide a minimal reproducible example?

niluxv commented 1 year ago

Hm, it seems to require using Trial::with_kind.

Example:

use libtest_mimic::{Arguments, Failed, Trial};

fn main() -> anyhow::Result<()> {
    let args = Arguments::from_args();
    let tests = vec![
        Trial::test("example.txt", erroring_test).with_kind("parse")
    ];
    libtest_mimic::run(&args, tests).exit();
}

fn erroring_test() -> Result<(), Failed> {
    // either return error or panic!, cargo nextest will still show as `PASS`
    //panic!();
    Err("Error, this doesn't work".into())
}
sunshowers commented 1 year ago

Ah thanks for the extended report. This is a bug in libtest-mimic.

sunshowers commented 1 year ago

I've proposed https://github.com/LukasKalbertodt/libtest-mimic/pull/30 in libtest-mimic which will fix this. For now, please avoid using with_kind.

niluxv commented 1 year ago

Thank you for looking into this!

sunshowers commented 6 months ago

This should be fixed with a libtest-mimic update. Thanks for the report!