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.

Prototyping a test runner feature using code lenses #173

Closed
@jonasbb

Description

@jonasbb

I am prototyping a way to use the code lens feature to run tests individually.

  1. Is there a way to determine which functions have the #[test] annotation? Unfortunately there is nothing similar in the save-analysis data.
  2. VS Code performs the code lens request right after opening the file. At this point the save-analysis data is not yet loaded and requests to self.analysis.symbols() fail.
    What would be a good way to synchronize a thread with the build thread such that the data is always loaded. Ideally, this would also allow me to wait for any re-builds after a change. This way I can ensure that the save-analysis data is always up-to-date and all ranges in the code lenses match the current file.

For 2. I was thinking that an atomic counter and a Condvar might work. The Condvar allows any thread to sleep until new save-analysis data is loaded. The atomic counter allows the thread to know that the save-analysis data is newer.

  1. Code Lens thread performs an atomic increment_and_get on the counter, stores the value in a variable, say c, and waits on the Condvar
  2. The build thread has finished building, performs the increment_and_get on the counter, stores both the counter value, say sa-c, and the save-analysis data, and notifies all threads waiting on the Condvar
  3. Any thread now woken up compares c with sa-c. If sa-c < c wait again otherwise the data can be used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementIndicates new feature requests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions