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

add ensureNoDisposablesAreLeakedInTestSuite() to some tests #203877

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,8 @@
"src/vs/editor/test/node/diffing/defaultLinesDiffComputer.test.ts",
"src/vs/editor/test/node/diffing/fixtures.test.ts",
"src/vs/platform/configuration/test/common/configuration.test.ts",
"src/vs/platform/contextkey/test/common/contextkey.test.ts",
"src/vs/platform/contextkey/test/common/parser.test.ts",
"src/vs/platform/contextkey/test/common/scanner.test.ts",
"src/vs/platform/extensions/test/common/extensionValidator.test.ts",
"src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts",
"src/vs/platform/keybinding/test/common/keybindingLabels.test.ts",
"src/vs/platform/keybinding/test/common/keybindingResolver.test.ts",
"src/vs/platform/opener/test/common/opener.test.ts",
"src/vs/platform/registry/test/common/platform.test.ts",
"src/vs/platform/remote/test/common/remoteHosts.test.ts",
Expand All @@ -184,7 +179,6 @@
"src/vs/workbench/contrib/tasks/test/common/taskConfiguration.test.ts",
"src/vs/workbench/services/commands/test/common/commandService.test.ts",
"src/vs/workbench/services/extensions/test/common/extensionDescriptionRegistry.test.ts",
"src/vs/workbench/services/keybinding/test/browser/keybindingIO.test.ts",
"src/vs/workbench/services/keybinding/test/node/fallbackKeyboardMapper.test.ts",
"src/vs/workbench/services/keybinding/test/node/macLinuxKeyboardMapper.test.ts",
"src/vs/workbench/services/keybinding/test/node/windowsKeyboardMapper.test.ts",
Expand Down
4 changes: 4 additions & 0 deletions src/vs/platform/contextkey/test/common/contextkey.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform';
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
import { ContextKeyExpr, ContextKeyExpression, implies } from 'vs/platform/contextkey/common/contextkey';

function createContext(ctx: any) {
Expand All @@ -15,6 +16,9 @@ function createContext(ctx: any) {
}

suite('ContextKeyExpr', () => {

ensureNoDisposablesAreLeakedInTestSuite();

test('ContextKeyExpr.equals', () => {
const a = ContextKeyExpr.and(
ContextKeyExpr.has('a1'),
Expand Down
3 changes: 3 additions & 0 deletions src/vs/platform/contextkey/test/common/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
import { Parser } from 'vs/platform/contextkey/common/contextkey';

function parseToStr(input: string): string {
Expand Down Expand Up @@ -34,6 +35,8 @@ function parseToStr(input: string): string {

suite('Context Key Parser', () => {

ensureNoDisposablesAreLeakedInTestSuite();

test(' foo', () => {
const input = ' foo';
assert.deepStrictEqual(parseToStr(input), "foo");
Expand Down
4 changes: 4 additions & 0 deletions src/vs/platform/contextkey/test/common/scanner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
import { Scanner, Token, TokenType } from 'vs/platform/contextkey/common/scanner';

suite('Context Key Scanner', () => {

ensureNoDisposablesAreLeakedInTestSuite();

function tokenTypeToStr(token: Token) {
switch (token.type) {
case TokenType.LParen:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { createSimpleKeybinding, ResolvedKeybinding, KeyCodeChord, Keybinding }
import { Disposable } from 'vs/base/common/lifecycle';
import { OS } from 'vs/base/common/platform';
import Severity from 'vs/base/common/severity';
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { ContextKeyExpr, ContextKeyExpression, IContext, IContextKeyService, IContextKeyServiceTarget } from 'vs/platform/contextkey/common/contextkey';
import { AbstractKeybindingService } from 'vs/platform/keybinding/common/abstractKeybindingService';
Expand Down Expand Up @@ -108,6 +109,18 @@ suite('AbstractKeybindingService', () => {
let statusMessageCalls: string[] | null = null;
let statusMessageCallsDisposed: string[] | null = null;


teardown(() => {
currentContextValue = null;
executeCommandCalls = null!;
showMessageCalls = null!;
createTestKeybindingService = null!;
statusMessageCalls = null;
statusMessageCallsDisposed = null;
});

ensureNoDisposablesAreLeakedInTestSuite();

setup(() => {
executeCommandCalls = [];
showMessageCalls = [];
Expand Down Expand Up @@ -196,15 +209,6 @@ suite('AbstractKeybindingService', () => {
};
});

teardown(() => {
currentContextValue = null;
executeCommandCalls = null!;
showMessageCalls = null!;
createTestKeybindingService = null!;
statusMessageCalls = null;
statusMessageCallsDisposed = null;
});

function kbItem(keybinding: number | number[], command: string | null, when?: ContextKeyExpression): ResolvedKeybindingItem {
return new ResolvedKeybindingItem(
createUSLayoutResolvedKeybinding(keybinding, OS),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as assert from 'assert';
import { decodeKeybinding, createSimpleKeybinding, KeyCodeChord } from 'vs/base/common/keybindings';
import { KeyChord, KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { OS } from 'vs/base/common/platform';
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
import { ContextKeyExpr, ContextKeyExpression, IContext } from 'vs/platform/contextkey/common/contextkey';
import { KeybindingResolver, ResultKind } from 'vs/platform/keybinding/common/keybindingResolver';
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
Expand All @@ -23,6 +24,8 @@ function createContext(ctx: any) {

suite('KeybindingResolver', () => {

ensureNoDisposablesAreLeakedInTestSuite();

function kbItem(keybinding: number | number[], command: string, commandArgs: any, when: ContextKeyExpression | undefined, isDefault: boolean): ResolvedKeybindingItem {
const resolvedKeybinding = createUSLayoutResolvedKeybinding(keybinding, OS);
return new ResolvedKeybindingItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import { KeybindingParser } from 'vs/base/common/keybindingParser';
import { OperatingSystem } from 'vs/base/common/platform';
import { KeybindingIO } from 'vs/workbench/services/keybinding/common/keybindingIO';
import { createUSLayoutResolvedKeybinding } from 'vs/platform/keybinding/test/common/keybindingsTestUtils';
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';

suite('keybindingIO', () => {
ensureNoDisposablesAreLeakedInTestSuite();

test('serialize/deserialize', () => {

Expand Down