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
Description
I am prototyping a way to use the code lens feature to run tests individually.
- Is there a way to determine which functions have the
#[test]
annotation? Unfortunately there is nothing similar in the save-analysis data. - 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.
- Code Lens thread performs an atomic
increment_and_get
on the counter, stores the value in a variable, sayc
, and waits on theCondvar
- The build thread has finished building, performs the
increment_and_get
on the counter, stores both the counter value, saysa-c
, and the save-analysis data, and notifies all threads waiting on theCondvar
- Any thread now woken up compares
c
withsa-c
. Ifsa-c
<c
wait again otherwise the data can be used.