-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Ensure EventListeners for unittest test results are not registered multiple times
#2383
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2383 +/- ##
==========================================
+ Coverage 75.38% 75.39% +<.01%
==========================================
Files 309 309
Lines 14331 14332 +1
Branches 2537 2537
==========================================
+ Hits 10804 10806 +2
+ Misses 3518 3517 -1
Partials 9 9
Continue to review full report at Codecov.
|
unittest test results are not registered multiple timesunittest test results are not registered multiple times
|
I attempted to correct how I'm registering the callbacks to limit the number of times we need to register/unregister, but I've not been successful. If I register each time we run tests, then unregister, it solves the problem. This is the solution I'm proposing with this PR. Ideally though, I'd want to simply register the events once in the constructor (or alternatively, in a single-shot 'register once then skip subsequent registrations' method). And never unregister my event handlers for the duration of the execution of the extension. This seems simpler to me. However, I haven't been able to successfully register once and have it work, I am 100% open to suggestions as I think my ideal solution would be simpler! |
| @@ -1,13 +1,22 @@ | |||
| // Copyright (c) Microsoft Corporation. All rights reserved. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a new file, so don't add the copyright header.
| }); | ||
|
|
||
| this.server.on('socket.disconnected', (socket: Socket, isSocketDestroyed: boolean) => { | ||
| this.server.removeAllListeners('error'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a list of all the possible values to make sure this doesn't skew in the future if more options come up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I can improve upon this and just remove all event listeners altogether. I'll do that as it seems more forward-thinking.
Fixes microsoft#2143 - Unregister listeners from socket service after each test run
- Update related code files to correct for linter errors - Add (commented out) unit test method - Create Python test files for test count issues
- NOTE: 2x test works, (3+N)x does not. - Perhaps a timeout issue, but might be worse - Will try a different solution to see if I can get this sorted.
Not a new file.
- allow for not specifying the specific event listener to remove
Fixes #2143, unit test counts in the VSCode status bar are not reflecting correct quantities.