Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAllow line numbers in addition to test name for focusing tests #45765
Comments
thegranddesign
referenced this issue
Nov 4, 2017
Closed
Allow line numbers in addition to test name for focusing tests #4693
This comment has been minimized.
This comment has been minimized.
|
Maybe I'm missing something, but "run the test under the cursor" seems like a feature that should be implemented as a macro/plugin for the editor, while rust/cargo should just take a test name. Especially since your editor might be auto-editing the file for various reasons, including auto-formatting that might change line numbers around at (from rust/cargo's point of view) random times. But I totally agree that "run the test under the cursor" should get implemented. |
This comment has been minimized.
This comment has been minimized.
|
I absolutely get what you’re saying. I think the point I’m trying to make is that this is a general requirement for editors and making each editor have its own logic for doing something like this (each of which can have its own set of bugs) in each of their own plugins seems like an inelegant solution. I agree that this would have to be determined prior to any code transforms (eg macros) happening. |
This comment has been minimized.
This comment has been minimized.
|
As far as auto formatting in the editor, that is absolutely the user’s/editor’s job to deal with. That’s not rust’s responsibility. As long as there’s a way to run the tests on a given line, that should be all rust has to care about. |
This comment has been minimized.
This comment has been minimized.
|
It is certainly possible to do this on the IDE level, IntelliJ does this, and RLS should be able to too. |
thegranddesign commentedNov 4, 2017
When working in an editor and scripting test runs in an automated fashion, it's much more practical to be able to specify the line number rather than trying to parse the file to determine the test name.
For example:
It's quite difficult to parse backwards line by line to find the previous
fnstatement (which is problematic in itself) and then pull out theit_can_add_thingssection of the line before finally constructing the full command.All editors have a capability to determine the current line and thus, assuming I'm on line
5(theassertline), running something likecargo test 5orcargo test --lines=5is very straightforward.Bonus points would include ranges and comma separated lists:
cargo test --lines=1-10,21This feature would effectively allow "run the test under the cursor" which is something that I do constantly during the day in other languages.