Skip to content

Commit

Permalink
vscode-go: update @types/vscode and engines.vscode
Browse files Browse the repository at this point in the history
For golang#2225.

Change-Id: I03af4d8f45c5f013f2492903c772e89fa578a83d
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/406305
Run-TryBot: Jamal Carvalho <[email protected]>
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
Reviewed-by: Suzy Mueller <[email protected]>
TryBot-Result: kokoro <[email protected]>
  • Loading branch information
jamalc committed May 18, 2022
1 parent 7c79ef4 commit 1660a85
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 31 deletions.
40 changes: 32 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@types/node": "13.13.46",
"@types/semver": "7.3.4",
"@types/sinon": "9.0.11",
"@types/vscode": "1.59.0",
"@types/vscode": "1.67.0",
"@vscode/test-electron": "2.0.2",
"adm-zip": "0.4.16",
"esbuild": "0.12.21",
Expand All @@ -89,7 +89,7 @@
"yarn": "1.22.10"
},
"engines": {
"vscode": "^1.59.0"
"vscode": "^1.67.0"
},
"activationEvents": [
"onLanguage:go",
Expand Down
7 changes: 4 additions & 3 deletions src/goDeveloperSurvey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function shouldPromptForSurvey(now: Date, cfg: DeveloperSurveyConfig): De
}

export async function promptForDeveloperSurvey(cfg: DeveloperSurveyConfig, now: Date): Promise<DeveloperSurveyConfig> {
let selected = await vscode.window.showInformationMessage(
const selected = await vscode.window.showInformationMessage(
// TODO(rstambler): Figure out how to phrase this.
`Looks like you are coding in Go! Would you like to help ensure that Go is meeting your needs
by participating in this 10-minute survey before ${endDate.toDateString()}?`,
Expand Down Expand Up @@ -153,10 +153,10 @@ by participating in this 10-minute survey before ${endDate.toDateString()}?`,

vscode.window.showInformationMessage("No problem! We'll ask you again another time.");
break;
case 'Never':
case 'Never': {
cfg.prompt = false;

selected = await vscode.window.showInformationMessage(
const selected = await vscode.window.showInformationMessage(
`No problem! We won't ask again.
If you'd like to opt-out of all survey prompts, you can set 'go.survey.prompt' to false.`,
'Open Settings'
Expand All @@ -169,6 +169,7 @@ If you'd like to opt-out of all survey prompts, you can set 'go.survey.prompt' t
break;
}
break;
}
default:
// If the user closes the prompt without making a selection, treat it
// like a "Not now" response.
Expand Down
7 changes: 4 additions & 3 deletions src/goSurvey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async function promptForGoplsSurvey(
cfg: GoplsSurveyConfig = {},
now: Date
): Promise<GoplsSurveyConfig> {
let selected = await vscode.window.showInformationMessage(
const selected = await vscode.window.showInformationMessage(
`Looks like you are using the Go extension for VS Code.
Could you help us improve this extension by filling out a 1-2 minute survey about your experience with it?`,
'Yes',
Expand Down Expand Up @@ -182,10 +182,10 @@ Could you help us improve this extension by filling out a 1-2 minute survey abou

vscode.window.showInformationMessage("No problem! We'll ask you again another time.");
break;
case 'Never':
case 'Never': {
cfg.prompt = false;

selected = await vscode.window.showInformationMessage(
const selected = await vscode.window.showInformationMessage(
`No problem! We won't ask again.
To opt-out of all survey prompts, please disable the 'Go > Survey: Prompt' setting.`,
'Open Settings'
Expand All @@ -198,6 +198,7 @@ To opt-out of all survey prompts, please disable the 'Go > Survey: Prompt' setti
break;
}
break;
}
default:
// If the user closes the prompt without making a selection, treat it
// like a "Not now" response.
Expand Down
3 changes: 2 additions & 1 deletion src/goTest/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class TestRunOutput implements OutputChannel {
show(...args: unknown[]) {}
hide() {}
dispose() {}
replace() {}
}

export class GoTestRunner {
Expand Down Expand Up @@ -400,7 +401,7 @@ export class GoTestRunner {
async collectTests(
item: TestItem,
explicitlyIncluded: boolean,
excluded: TestItem[],
excluded: readonly TestItem[],
functions: Map<TestItem, CollectedTest[]>,
files: Set<TestItem>
) {
Expand Down
1 change: 1 addition & 0 deletions test/gopls/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class FakeOutputChannel implements vscode.OutputChannel {
public show = sinon.fake(); // no-empty
public hide = sinon.fake(); // no-empty
public dispose = sinon.fake(); // no-empty
public replace = sinon.fake(); // no-empty

private buf = [] as string[];

Expand Down
27 changes: 22 additions & 5 deletions test/integration/goTest.explore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ suite('Go Test Explorer', () => {
doc.contents = contents;
await expl._didChange({
document: doc,
contentChanges: []
contentChanges: [],
reason: undefined
});
}

Expand Down Expand Up @@ -333,7 +334,11 @@ suite('Go Test Explorer', () => {
expectedTests
);

await explorer.runner.run({ include: [tests[0]] });
await explorer.runner.run({
include: [tests[0]],
exclude: undefined,
profile: undefined
});
assert.strictEqual(runStub.callCount, 1, 'Expected goTest to be called once');
assert.deepStrictEqual(runStub.lastCall.args[0].functions, ['TestFoo']);
});
Expand All @@ -350,7 +355,11 @@ suite('Go Test Explorer', () => {
expectedTests
);

await explorer.runner.run({ include: [tests[0]] });
await explorer.runner.run({
include: [tests[0]],
exclude: undefined,
profile: undefined
});
assert.strictEqual(runStub.callCount, 2, 'Expected goTest to be called twice');
assert.deepStrictEqual(runStub.firstCall.args[0].functions, ['TestFoo']);
assert.deepStrictEqual(runStub.secondCall.args[0].functions, ['BenchmarkBar']);
Expand Down Expand Up @@ -393,7 +402,11 @@ suite('Go Test Explorer', () => {
.filter((x) => GoTest.parseId(x.id).name)[0];
assert(test, 'Could not find test');

await explorer.runner.run({ include: [test] });
await explorer.runner.run({
include: [test],
exclude: undefined,
profile: undefined
});
assert.strictEqual(runStub.callCount, 1, 'Expected goTest to be called once');

const subTest = test.children.get('file:///src/proj/main_test.go?test#TestFoo%2FBar');
Expand All @@ -413,7 +426,11 @@ suite('Go Test Explorer', () => {
.filter((x) => GoTest.parseId(x.id).name)[0];
assert(test, 'Could not find test');

await explorer.runner.run({ include: [test] });
await explorer.runner.run({
include: [test],
exclude: undefined,
profile: undefined
});
assert.strictEqual(runStub.callCount, 1, 'Expected goTest to be called once');

const subTest = test.children.get('file:///src/proj/main_test.go?test#TestFoo%2FBar');
Expand Down
56 changes: 50 additions & 6 deletions test/integration/goTest.run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,15 @@ suite('Go Test Runner', () => {
assert(test, 'No tests found');

assert(
await testExplorer.runner.run({ include: [test] }, undefined, { kind: 'cpu' }),
await testExplorer.runner.run(
{
include: [test],
exclude: undefined,
profile: undefined
},
undefined,
{ kind: 'cpu' }
),
'Failed to execute `go test`'
);
assert.strictEqual(stub.callCount, 1, 'expected one call to goTest');
Expand All @@ -64,7 +72,14 @@ suite('Go Test Runner', () => {
const tests = Array.from(testExplorer.resolver.allItems).filter((x) => GoTest.parseId(x.id).name);
assert(tests, 'No tests found');

assert(await testExplorer.runner.run({ include: tests }), 'Failed to execute `go test`');
assert(
await testExplorer.runner.run({
include: tests,
exclude: undefined,
profile: undefined
}),
'Failed to execute `go test`'
);
assert.strictEqual(stub.callCount, 1, 'expected one call to goTest');
assert.deepStrictEqual(
stub.lastCall.args[0].functions,
Expand All @@ -79,7 +94,15 @@ suite('Go Test Runner', () => {
console.log(`running ${tests.length} tests`);

assert(
await testExplorer.runner.run({ include: tests }, undefined, { kind: 'cpu' }),
await testExplorer.runner.run(
{
include: tests,
exclude: undefined,
profile: undefined
},
undefined,
{ kind: 'cpu' }
),
'Failed to execute `go test`'
);
console.log('verify we got expected calls');
Expand Down Expand Up @@ -129,7 +152,14 @@ suite('Go Test Runner', () => {

// Run TestMain
console.log('Run TestMain');
assert(await testExplorer.runner.run({ include: [tMain] }), 'Failed to execute `go test`');
assert(
await testExplorer.runner.run({
include: [tMain],
exclude: undefined,
profile: undefined
}),
'Failed to execute `go test`'
);
assert.strictEqual(spy.callCount, 1, 'expected one call to goTest');

// Verify TestMain was run
Expand All @@ -152,7 +182,14 @@ suite('Go Test Runner', () => {

// Run subtest by itself
console.log('Run subtest by itself');
assert(await testExplorer.runner.run({ include: [tSub] }), 'Failed to execute `go test`');
assert(
await testExplorer.runner.run({
include: [tSub],
exclude: undefined,
profile: undefined
}),
'Failed to execute `go test`'
);
assert.strictEqual(spy.callCount, 1, 'expected one call to goTest');

// Verify TestMain/Sub was run
Expand All @@ -168,7 +205,14 @@ suite('Go Test Runner', () => {

// Attempt to run subtest and other test - should not work
console.log('Attempt to run subtest and other test');
assert(await testExplorer.runner.run({ include: [tSub, tOther] }), 'Failed to execute `go test`');
assert(
await testExplorer.runner.run({
include: [tSub, tOther],
exclude: undefined,
profile: undefined
}),
'Failed to execute `go test`'
);
assert.strictEqual(spy.callCount, 0, 'expected no calls to goTest');
}).timeout(4000);
});
Expand Down
11 changes: 8 additions & 3 deletions test/mocks/MockTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
TestRunProfile,
TestRunProfileKind,
TestRunRequest,
TestTag,
TextDocument,
TextLine,
Uri,
Expand Down Expand Up @@ -77,13 +78,15 @@ class MockTestItem implements TestItem {
this.idNum = MockTestItem.idNum;
MockTestItem.idNum++;
}
tags: readonly TestTag[] = [];
sortText?: string | undefined;

parent: TestItem | undefined;
canResolveChildren = false;
busy = false;
description?: string;
range?: Range;
error?: string | MarkdownString;
range: Range | undefined;
error: string | MarkdownString | undefined;
runnable = false;
debuggable = false;

Expand All @@ -105,8 +108,9 @@ class MockTestRunProfile implements TestRunProfile {
public runHandler: TestRunHandler,
public isDefault: boolean
) {}
tag: TestTag | undefined;

configureHandler?: () => void;
configureHandler(): void {}
dispose(): void {}
}

Expand Down Expand Up @@ -134,6 +138,7 @@ export class MockTestController implements TestController {
items = new MockTestCollection(this);

resolveHandler?: (item: TestItem | undefined) => void | Thenable<void>;
refreshHandler: ((token: CancellationToken) => void | Thenable<void>) | undefined;

createTestRun(request: TestRunRequest, name?: string, persist?: boolean): TestRun {
return new MockTestRun();
Expand Down

0 comments on commit 1660a85

Please sign in to comment.