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

rust tests with #[test] #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

gbataille
Copy link
Contributor

Hi,

I have been trying to get nvim-test to run rust tests that do not have test in the name but that are annotated with #[test]

fn add(a: i32, b: i32) -> i32 {
    a + b
}

#[cfg(test)]
mod tests {
    use super::*;

    fn not_a_test() {
        assert_eq!(1, 2);
    }

    #[test]
    fn test_add3() {
        assert_eq!(add(1, 2), 3);
    }

    #[test]
    fn test_add5() {
        assert_eq!(add(3, 2), 5);
    }

    fn foo() {
        println!("{}", 'a' as u32);
    }

    #[test]
    fn test_ascii() {
        println!("{}", 'a' as u32);
        println!("{}", 'A' as u32);
    }
    #[test]
    fn bar() {
        println!("{}", 'a' as u32);
        println!("{}", 'A' as u32);
    }
}

mod foo {
    fn foobar() {
        println!("{}", 'a' as u32);
        println!("{}", 'A' as u32);
    }
}

I'm brand new to treesitter, and lua (and to rust too actually). Took me a while because you need an expression that matches a sibling from the function you are trying to find. I think you can't solve it by just fiddling with the treesitter expression and use the generic find_nearest_test of the Runner but I'm not sure at all.

I have tried a first implementation that works on the above example but I'm not very happy with it. I don't like the booleans that track the state of whether I have already found my targets and such, and I also guess that it might not work with other test patterns.

Questions

  • Are you interested in solving the problem (test tagged and not following a naming convention)
  • Any pointers you might give me?

(I have now seen that there are specs test, I'll need to try and run them too, I have not done that yet)

@gbataille
Copy link
Contributor Author

just found another bug with the way the rust tester is implemented
#28

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

Successfully merging this pull request may close these issues.

None yet

1 participant