Skip to content

Commit 3de9e1b

Browse files
authored
Nightly failure fixes (#1586)
* Capture promise before running command It times out after long wait so thinking there may be a timing issue here * Try match expression in case it's a equality issue * Try to do a better job of capturing further data after exit Inspiration from microsoft/vscode@9464b54 * Debug logging * Also check no floating thenables * Make command callbacks async * Fix failing test * See if using correct WorkspaceContext instance * More debug logging * Try to return instead of resolve * Specify expected arguments * Allow passing count as command parameter * Fix failing test * Debug logging * Run function directly * Make these unit tests Don't require activated extension to test these * Remove debug logging * Make sure debugger extensions are activated Only activate first time since never will deactivate * Only need one folder for this test * Remove more debug logging * Move to unit level * Fix review comment
1 parent c3dd31c commit 3de9e1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+314
-201
lines changed

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
// TODO "@typescript-eslint/semi" rule moved to https://eslint.style
1515
"semi": "error",
1616
"no-console": "warn",
17-
"@typescript-eslint/no-floating-promises": "warn",
17+
"@typescript-eslint/no-floating-promises": ["warn", { "checkThenables": true }],
18+
"@typescript-eslint/await-thenable": "warn",
1819
// Mostly fails tests, ex. expect(...).to.be.true returns a Chai.Assertion
1920
"@typescript-eslint/no-unused-expressions": "off",
2021
"@typescript-eslint/no-non-null-assertion": "off",

scripts/check_package_json.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import { getExtensionVersion, main } from "./lib/utilities";
1717

18+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
1819
main(async () => {
1920
const version = await getExtensionVersion();
2021
if (version.minor % 2 !== 0) {

scripts/compile_icons.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ function minifyIcon(icon: string, color: string = "#424242"): string {
5151
}).data;
5252
}
5353

54+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
5455
main(async () => {
5556
const iconsSourceDirectory = path.join(__dirname, "../src/icons");
5657
const iconAssetsDirectory = path.join(__dirname, "../assets/icons");

scripts/dev_package.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import { exec, getExtensionVersion, getRootDirectory, main } from "./lib/utilities";
1717

18+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
1819
main(async () => {
1920
const rootDirectory = getRootDirectory();
2021
const version = await getExtensionVersion();

scripts/download_vsix.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const repository = process.env["GITHUB_REPOSITORY"] || "swiftlang/vscode-swift";
3333
const owner = repository.split("/")[0];
3434
const repo = repository.split("/")[1];
3535

36+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
3637
(async function () {
3738
const octokit = new Octokit({
3839
auth: token,

scripts/preview_package.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function formatDate(date: Date): string {
2828
return year + month + day;
2929
}
3030

31+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
3132
main(async () => {
3233
const rootDirectory = getRootDirectory();
3334
const version = await getExtensionVersion();

scripts/update_swift_docc_render.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ async function cloneSwiftDocCRender(buildDirectory: string): Promise<string> {
5656
return swiftDocCRenderDirectory;
5757
}
5858

59+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
5960
main(async () => {
6061
const outputDirectory = path.join(getRootDirectory(), "assets", "swift-docc-render");
6162
if (process.argv.includes("postinstall")) {

src/FolderContext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export class FolderContext implements vscode.Disposable {
9393

9494
const error = await swiftPackage.error;
9595
if (error) {
96-
vscode.window.showErrorMessage(
96+
void vscode.window.showErrorMessage(
9797
`Failed to load ${folderContext.name}/Package.swift: ${error.message}`
9898
);
9999
workspaceContext.outputChannel.log(
@@ -179,7 +179,7 @@ export class FolderContext implements vscode.Disposable {
179179
/** Refresh the tests in the test explorer for this folder */
180180
refreshTestExplorer() {
181181
if (this.testExplorer?.controller.resolveHandler) {
182-
this.testExplorer.controller.resolveHandler(undefined);
182+
void this.testExplorer.controller.resolveHandler(undefined);
183183
}
184184
}
185185

src/TestExplorer/TestExplorer.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ export class TestExplorer {
204204
*/
205205
private updateSwiftTestContext() {
206206
const items = flattenTestItemCollection(this.controller.items).map(({ id }) => id);
207-
vscode.commands.executeCommand("setContext", "swift.tests", items);
207+
void vscode.commands.executeCommand("setContext", "swift.tests", items).then(() => {
208+
/* Put in worker queue */
209+
});
208210
}
209211

210212
/**
@@ -285,7 +287,7 @@ export class TestExplorer {
285287
const ok = "OK";
286288
const enable = "Enable SourceKit-LSP";
287289
if (firstTry && configuration.lsp.disable === true) {
288-
vscode.window
290+
void vscode.window
289291
.showInformationMessage(
290292
`swift-testing tests will not be detected since SourceKit-LSP
291293
has been disabled for this workspace.`,
@@ -297,9 +299,12 @@ export class TestExplorer {
297299
explorer.folderContext.workspaceContext.outputChannel.log(
298300
`Enabling SourceKit-LSP after swift-testing message`
299301
);
300-
vscode.workspace
302+
void vscode.workspace
301303
.getConfiguration("swift")
302-
.update("sourcekit-lsp.disable", false);
304+
.update("sourcekit-lsp.disable", false)
305+
.then(() => {
306+
/* Put in worker queue */
307+
});
303308
} else if (selected === ok) {
304309
explorer.folderContext.workspaceContext.outputChannel.log(
305310
`User acknowledged that SourceKit-LSP is disabled`

src/TestExplorer/TestRunner.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,8 +1021,7 @@ export class TestRunner {
10211021
"Test Debugging Cancelled",
10221022
this.folderContext.name
10231023
);
1024-
vscode.debug.stopDebugging(session);
1025-
resolve();
1024+
void vscode.debug.stopDebugging(session).then(() => resolve());
10261025
});
10271026
subscriptions.push(cancellation);
10281027
});
@@ -1051,11 +1050,9 @@ export class TestRunner {
10511050
// dispose terminate debug handler
10521051
subscriptions.forEach(sub => sub.dispose());
10531052

1054-
vscode.commands.executeCommand(
1055-
"workbench.view.extension.test"
1056-
);
1057-
1058-
resolve();
1053+
void vscode.commands
1054+
.executeCommand("workbench.view.extension.test")
1055+
.then(() => resolve());
10591056
});
10601057
subscriptions.push(terminateSession);
10611058
} else {

0 commit comments

Comments
 (0)