Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Allow line numbers in addition to test name for focusing tests #1547

@thegranddesign

Description

@thegranddesign

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:

#[cfg(test)]
mod tests {
    #[test]
    fn it_can_add_things() {
        assert!(2 + 2, 4)
    }
}

It's quite difficult to parse backwards line by line to find the previous fn statement (which is problematic in itself) and then pull out the it_can_add_things section 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 (the assert line), running something like cargo test 5 or cargo test --lines=5 is very straightforward.

Bonus points would include ranges and comma separated lists: cargo test --lines=1-10,21

This feature would effectively allow "run the test under the cursor" which is something that I do constantly during the day in other languages.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions