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)
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]
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 theRunner
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
(I have now seen that there are specs test, I'll need to try and run them too, I have not done that yet)