Skip to content
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

Dispose instances of test instantiation service #187482

Merged
merged 5 commits into from
Jul 11, 2023

Conversation

alexr00
Copy link
Member

@alexr00 alexr00 commented Jul 10, 2023

This will call sinon.restore() and prevent a memory leak
Part of #187471

@alexr00 alexr00 enabled auto-merge (squash) July 10, 2023 15:39
@alexr00 alexr00 self-assigned this Jul 10, 2023
@VSCodeTriageBot VSCodeTriageBot added this to the July 2023 milestone Jul 10, 2023
@alexr00 alexr00 marked this pull request as draft July 10, 2023 16:04
auto-merge was automatically disabled July 10, 2023 16:04

Pull request was converted to draft

@alexr00
Copy link
Member Author

alexr00 commented Jul 10, 2023

@sandy081 A bunch (all?) of the ExtensionsWorkbenchServiceTest tests are failing, though my change shouldn't affect them. Are they possibly relying on mocking from another test suite?

@alexr00
Copy link
Member Author

alexr00 commented Jul 10, 2023

Same for ExtensionRecommendationsService.

@sandy081
Copy link
Member

Instead of restoring on dispose, is it possible to hook at the end of each test file and restore?

@sandy081
Copy link
Member

I did a new change that restore the stubs after every test file - #187496 - I ran some builds with this change enabling unit tests in windows 32 bit and they seem to run. But there is one unit test that is failing consistently in Mac.

@@ -129,6 +129,10 @@ export class TestInstantiationService extends InstantiationService {
override createChild(services: ServiceCollection): TestInstantiationService {
return new TestInstantiationService(services, false, this);
}

dispose() {
sinon.restore();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think calling restore on sinon here might not be correct as this will restore all sinon stubs that this service does not own.

@alexr00
Copy link
Member Author

alexr00 commented Jul 11, 2023

I did a new change that restore the stubs after every test file - #187496 - I ran some builds with this change enabling unit tests in windows 32 bit and they seem to run. But there is one unit test that is failing consistently in Mac.

After discussing in standup the outcome was that we should properly clean up after each test/test suite and should not use a hook to restore after every test file.

This will call `sinon.restore()` and prevent a memory leak
Part of #187471
@alexr00 alexr00 force-pushed the alexr00/disposeTestInstaService branch from 4910d9c to 67d35f8 Compare July 11, 2023 09:52
@alexr00 alexr00 marked this pull request as ready for review July 11, 2023 10:37
suite('DecorationAddon', async () => {
suite('DecorationAddon', () => {
let decorationAddon: DecorationAddon;
let xterm: any;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@meganrogge and @Tyriar I know this any is not ideal, but having the async suite here causes the async code to run while other tests are running and can interfere with the other tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good, you should be able to import the type like this still though:

import type { IBuffer, ITheme, Terminal as RawXtermTerminal, LogLevel as XtermLogLevel } from 'xterm';

suite('DecorationAddon', async () => {
suite('DecorationAddon', () => {
let decorationAddon: DecorationAddon;
let xterm: any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good, you should be able to import the type like this still though:

import type { IBuffer, ITheme, Terminal as RawXtermTerminal, LogLevel as XtermLogLevel } from 'xterm';

lszomoru
lszomoru previously approved these changes Jul 11, 2023
@alexr00 alexr00 enabled auto-merge (squash) July 11, 2023 12:10
@alexr00 alexr00 merged commit f0db763 into main Jul 11, 2023
6 checks passed
@alexr00 alexr00 deleted the alexr00/disposeTestInstaService branch July 11, 2023 12:23
Ulop pushed a commit to Megaputer/vscode that referenced this pull request Jul 11, 2023
* Dispose instances of test instantiation service
This will call `sinon.restore()` and prevent a memory leak
Part of microsoft#187471

* Fix interfering terminal tests

* Remove `async` from terminal test suite

* Fix `any`
@alexr00 alexr00 restored the alexr00/disposeTestInstaService branch July 12, 2023 08:17
@alexr00 alexr00 deleted the alexr00/disposeTestInstaService branch July 12, 2023 09:47
@github-actions github-actions bot locked and limited conversation to collaborators Aug 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants