Skip to content

Feature request: Add a bazel Runnable kind #12105

Open
@petr-tik

Description

@petr-tik

As a developer using rust-analyzer with bazel (using rules_rust and rust-project.json generated by @rules_rust//tools/rust_analyzer:gen_rust_project)
I would like rust-analyzer to use bazel test for test runnables
so that I can enjoy the same UX regardless of the build system.

The Runnables extension is a great productivity boost and it's very easy to run a test
from a code lens. According to my experiments and the lsp-extensions.md documentation, it
currently only supports one Runnable.kind = "cargo".

Given the consistency and stability of the bazel test intereface, we should be able to use bazel test and pass additional command line arguments

bazel test //path_to_rust_package:rust_test_name --test_arg $THE_TEST_SELECTED_BY_USER

While the --test_arg is definitely something that rust-analyzer can already reliable populate, working out the //path_to_rust_package:rust_test_name might require an expansion to rules_rust to add test targets to rust-project.json file.

Once this is implemented, the same interface could be used for the Related Tests extension.

For rust-analyzer to automatically work out the runnable kind is "bazel", rules_rust can add a field to rust-project.json that declares runnable kind to be bazel (or we can heuristically guess?).

For the rest, rust-analyzer works like a charm with bazel, so thanks very much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-configconfigurationA-idegeneral IDE featuresC-enhancementCategory: enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions