Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running a single test fails #50

Closed
ErezAmihud opened this issue Sep 13, 2023 · 2 comments
Closed

Running a single test fails #50

ErezAmihud opened this issue Sep 13, 2023 · 2 comments
Labels
question Further information is requested

Comments

@ErezAmihud
Copy link
Contributor

ErezAmihud commented Sep 13, 2023

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
Copy link
Owner

rouge8 commented Sep 16, 2023

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.

@rouge8 rouge8 added the question Further information is requested label Sep 16, 2023
@ErezAmihud
Copy link
Contributor Author

ErezAmihud commented Sep 16, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants