rouge8 / neotest-rust

Neotest adapter for Rust, using cargo-nextest.
MIT License
91 stars 27 forks source link

Running a single test fails #50

Closed ErezAmihud closed 1 year ago

ErezAmihud commented 1 year ago

Hello, I have the following file:

use std::num::ParseIntError;
fn number_sum(data:&str) -> Result<u32, ParseIntError>{ 
    let mut ot = Vec::new();
    for line in data.split("\n"){
        ot.push(line.parse::<u32>()?);
    }
    Ok(ot.iter().sum())
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_number_list_sum_ok(){
        assert_eq!(number_sum("323\n392").unwrap(), 323+392);
    }
    #[test]
    fn test_number_list_sum_error(){
        assert!(number_sum("hi\n392").is_err());
    }
}

When trying to run only the test_number_list_sum_error test (via the neotest sidebar) I get the following error:

error: expected expression
   ╭────
 1 │ 'test(/tests::test_number_list_sum_error$/)'
   · ──────────────────────┬─────────────────────
   ·                       ╰── missing expression
   ╰────

  error: expected end of expression
   ╭────
 1 │ 'test(/tests::test_number_list_sum_error$/)'
   · ──────────────────────┬─────────────────────
   ·                       ╰── unparsed input
   ╰────

error: failed to parse filter expression

Or in a photo:

image

NOTE that when running the entire tests module everything works.

rouge8 commented 1 year ago

Works for me. Can you provide an example repo that fails? I generated a new project with cargo new --lib gh50 and replaced lib.rs with your sample above and everything was fine.

ErezAmihud commented 1 year ago

Works for me. Can you provide an example repo that fails? I generated a new project with cargo new --lib gh50 and replaced lib.rs with your sample above and everything was fine.

Here is the example repo It appears the problem only happens on windows. On linux it worked just fine. I have updated all of my plugins (tree sitter and such), and my nvim version is v0.9.0.

Edit: After more triel and error I found that running cargo nextest run -E 'test(/^tests::test_number_list_sum_ok$/)' in linux works while on windows it does not. This is (part of) the command line that runs in the terminal by neotest

Other Edit: I found that changing the ' to " makes it work on both systems, I will create a pr soon