rust-lang / rust-lang/rust-analyzer

Live/incremental testing

Open
#8,420 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

fun S-unactionable
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Further to discussion on Zulip a while back, this issue is to track what's required to achieve "Live/incremental testing" for Rust (à la Wallaby.js and Visual Studio); the goal is for RA to run only those tests that have been affected by edits and display the results inline.

The broad design in mind for this is as follows:

  • tests are compiled with instrumentation that can determine the set of code regions* that each exercises
  • initial run of all tests constructs two maps:
    • one from each code region to the set of tests that cover it; and
    • one from each test to both its result (including point of failure) and the set of code regions that it covers
  • each code region displays some visual indication of the aggregate results of its covering tests, with points of failure clearly indicated
  • when a code region is modified**, all its covering tests are queued for execution
  • when a test is executed, the maps and visual indications are updated

* The ultimate solution would probably instrument at the level of basic blocks, eg via -Zinstrument-coverage—but this (presently) requires LLVM, whereas cg-clif is probably a better fit for this feature overall (e.g. because hot-swapped JIT can help minimise compilation times); instrumenting at the function level may be more easily achievable at the outset.

** The ultimate solution would probably enqueue affected tests as code is being edited—but this requires virtual files to be shared from RA to rustc for compilation, and currently rustc is not called in-process; queuing affected tests on save may be more achievable at the outset.

On the UI front, it's probably worth noting that VSCode may get some sort of API for precisely this over the next couple of months.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Zulip discussion and the referenced rustc_codegen_cranelift issues on coverage instrumentation and hot-swapped JIT. Define the scope around tracking code-region/test coverage, rerunning affected tests, and displaying inline results; the issue does not name implementation files or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools, testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.