Fix race condition in VS Code debugger integration tests #2649
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed a race condition in the Q# and OpenQASM debugger integration tests that was causing intermittent test failures.
Problem:
scopes
andvariables
requestsChanges:
waitUntilResponse()
method to track specific command responseswaitUntilPausedAndAssertStackTrace()
andwaitUntilPausedAndAssertVariables()
into a singlewaitUntilPaused()
method with optionsThe fix ensures tests consistently read variables from the correct stack frame by waiting for their own requests to complete rather than potentially intercepting VS Code's internal debugger communication.
Examples (VS Code's requests in purple, our test's requests in red):
Before, bad run:
VS Code comes in with the variables request, the
variablesReference
changes from 1003 to 1006, and our request ends up using the wrong id (and the test potentially uses the wron response object too)Before, good run:
We intercepted VS Code, so the
variablesReference
1003 happened to workFixed:
We waited until the debugger was paused and VS Code was out of the way, and then sent a scopes request to get the proper
variablesReference
to call with.