Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

"Run test" code lens runs all tests with a matching name #625

Open
oli-cosmian opened this issue Jul 22, 2019 · 3 comments
Open

"Run test" code lens runs all tests with a matching name #625

oli-cosmian opened this issue Jul 22, 2019 · 3 comments

Comments

@oli-cosmian
Copy link

The lens on foo_bar will only run the foo_bar test, but the lens on foo will run both tests.

mod a {
    #[test] fn foo() {}
}
mod b {
    #[test] fn foo_bar() {}
}

The lens should pass the module path to the cargo test invocation in order to not run all tests with a matching name

@janriemer
Copy link

I am having the same issue.

@Gowee
Copy link
Contributor

Gowee commented Nov 2, 2019

The problem is that the current implementation of CodeLens in rls simply uses RegEx to locate the fn name and passes it to cargo test without parsing source code or mod structures.

https://github.com/rust-lang/rls/blob/adf13c2527d3a11850fb0f79323768596f78f4f2/rls/src/actions/run.rs#L51

I think it is nearly impossible to fix without a non-trivial refactor.

@yujingaya
Copy link

I had same problem and investigated rls and cargo-test.

It seems --exact flag with fully qualified name of the test function, like a::b::tests::test_name, will do the job. But as @Gowee said above, it requires some understanding of rls.

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

No branches or pull requests

4 participants