-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test-Provider-Sample: Continuous RunHandler registers redundantly #900
Comments
For my Pester Tests extension, I ended up doing the following:
An alternative approach would be to use events and register events on a testItem basis rather than a Uri basis, if your testRunner doesnt need debouncing. |
This is kind of an artifact of the way the sample test provider is set up: a test identity is defined by the equation its testing, so changing a test will actually delete the old test and make a new one with a different equation. Therefore watching at a file level is the rough approximation of what continuous mode is meant to represent. |
@connor4312 the issue is more this (to reproduce):
EDIT: As an extreme extrapolation of above, I marked 5 different tests for continous run, and then saved a change to the file once. Notice 5 redundant job runners kicked off (because 5 full-file listeners are now registered) |
It's up to the test extension as to how they want to handle that multiple watch requests. I should update the sample to deal with it better. Watching a test requires the extension maintains state, and it's expected that further watches, if precise per-test watching is not possible (as in the sample extension) that the test extension deduplicates at whatever granularity is appropriate. In this case VS Code does not 'know' that watching two different tests in the same file results in duplicated behavior in the extension side. |
@connor4312 agreed, I was just noting in this case there's an issue with how the sample currently handles it. |
@connor4312 thanks! 🤘 |
@connor4312
https://github.com/microsoft/vscode-extension-samples/blob/ead2640188c31d12ad07ed4d3c0d47d5b54a23c8/test-provider-sample/src/extension.ts#L9C1-L23C4
In this section, the
runhandler
registers an event for when files change to trigger a test run request ifcontinuous
is set, which from my testing only occurs currently when someone clicks the "eye" next to a test. The problem is that it is not test-level based but URI based, so it will both re-run all tests in the markdown file and not just the ones specifically specified, and also if you flag multiple tests in the same file for continuous, multiple full-file handlers get registered, so say you flag two different tests in the same file, the test run will happen twice upon saving changes to the file.If I am understanding this correctly, a better approach would be upon a file change detected, first identify which tests changed, and then have a flag somewhere such as the testItemData where it shows if the test should be continuous or not, and then run it if that is the case. An alternative would be to register an event for each individual test item that either runs the tests in parallel, or calls a debouncing function so they can all be run together after a short debounce delay (depending on whether the test runner is more efficient on a per-test or per-test-file basis).
The text was updated successfully, but these errors were encountered: