Skip to content

Nightly failure fixes #1586

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

Merged
merged 22 commits into from
May 27, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
// TODO "@typescript-eslint/semi" rule moved to https://eslint.style
"semi": "error",
"no-console": "warn",
"@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-floating-promises": ["warn", { "checkThenables": true }],
"@typescript-eslint/await-thenable": "warn",
// Mostly fails tests, ex. expect(...).to.be.true returns a Chai.Assertion
"@typescript-eslint/no-unused-expressions": "off",
"@typescript-eslint/no-non-null-assertion": "off",
Expand Down
1 change: 1 addition & 0 deletions scripts/check_package_json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

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

// eslint-disable-next-line @typescript-eslint/no-floating-promises
main(async () => {
const version = await getExtensionVersion();
if (version.minor % 2 !== 0) {
Expand Down
1 change: 1 addition & 0 deletions scripts/compile_icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function minifyIcon(icon: string, color: string = "#424242"): string {
}).data;
}

// eslint-disable-next-line @typescript-eslint/no-floating-promises
main(async () => {
const iconsSourceDirectory = path.join(__dirname, "../src/icons");
const iconAssetsDirectory = path.join(__dirname, "../assets/icons");
Expand Down
1 change: 1 addition & 0 deletions scripts/dev_package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

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

// eslint-disable-next-line @typescript-eslint/no-floating-promises
main(async () => {
const rootDirectory = getRootDirectory();
const version = await getExtensionVersion();
Expand Down
1 change: 1 addition & 0 deletions scripts/download_vsix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const repository = process.env["GITHUB_REPOSITORY"] || "swiftlang/vscode-swift";
const owner = repository.split("/")[0];
const repo = repository.split("/")[1];

// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async function () {
const octokit = new Octokit({
auth: token,
Expand Down
1 change: 1 addition & 0 deletions scripts/preview_package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function formatDate(date: Date): string {
return year + month + day;
}

// eslint-disable-next-line @typescript-eslint/no-floating-promises
main(async () => {
const rootDirectory = getRootDirectory();
const version = await getExtensionVersion();
Expand Down
1 change: 1 addition & 0 deletions scripts/update_swift_docc_render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ async function cloneSwiftDocCRender(buildDirectory: string): Promise<string> {
return swiftDocCRenderDirectory;
}

// eslint-disable-next-line @typescript-eslint/no-floating-promises
main(async () => {
const outputDirectory = path.join(getRootDirectory(), "assets", "swift-docc-render");
if (process.argv.includes("postinstall")) {
Expand Down
4 changes: 2 additions & 2 deletions src/FolderContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class FolderContext implements vscode.Disposable {

const error = await swiftPackage.error;
if (error) {
vscode.window.showErrorMessage(
void vscode.window.showErrorMessage(
`Failed to load ${folderContext.name}/Package.swift: ${error.message}`
);
workspaceContext.outputChannel.log(
Expand Down Expand Up @@ -179,7 +179,7 @@ export class FolderContext implements vscode.Disposable {
/** Refresh the tests in the test explorer for this folder */
refreshTestExplorer() {
if (this.testExplorer?.controller.resolveHandler) {
this.testExplorer.controller.resolveHandler(undefined);
void this.testExplorer.controller.resolveHandler(undefined);
}
}

Expand Down
13 changes: 9 additions & 4 deletions src/TestExplorer/TestExplorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ export class TestExplorer {
*/
private updateSwiftTestContext() {
const items = flattenTestItemCollection(this.controller.items).map(({ id }) => id);
vscode.commands.executeCommand("setContext", "swift.tests", items);
void vscode.commands.executeCommand("setContext", "swift.tests", items).then(() => {
/* Put in worker queue */
});
}

/**
Expand Down Expand Up @@ -285,7 +287,7 @@ export class TestExplorer {
const ok = "OK";
const enable = "Enable SourceKit-LSP";
if (firstTry && configuration.lsp.disable === true) {
vscode.window
void vscode.window
.showInformationMessage(
`swift-testing tests will not be detected since SourceKit-LSP
has been disabled for this workspace.`,
Expand All @@ -297,9 +299,12 @@ export class TestExplorer {
explorer.folderContext.workspaceContext.outputChannel.log(
`Enabling SourceKit-LSP after swift-testing message`
);
vscode.workspace
void vscode.workspace
.getConfiguration("swift")
.update("sourcekit-lsp.disable", false);
.update("sourcekit-lsp.disable", false)
.then(() => {
/* Put in worker queue */
});
} else if (selected === ok) {
explorer.folderContext.workspaceContext.outputChannel.log(
`User acknowledged that SourceKit-LSP is disabled`
Expand Down
11 changes: 4 additions & 7 deletions src/TestExplorer/TestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,7 @@ export class TestRunner {
"Test Debugging Cancelled",
this.folderContext.name
);
vscode.debug.stopDebugging(session);
resolve();
void vscode.debug.stopDebugging(session).then(() => resolve());
});
subscriptions.push(cancellation);
});
Expand Down Expand Up @@ -1051,11 +1050,9 @@ export class TestRunner {
// dispose terminate debug handler
subscriptions.forEach(sub => sub.dispose());

vscode.commands.executeCommand(
"workbench.view.extension.test"
);

resolve();
void vscode.commands
.executeCommand("workbench.view.extension.test")
.then(() => resolve());
});
subscriptions.push(terminateSession);
} else {
Expand Down
10 changes: 7 additions & 3 deletions src/WorkspaceContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class WorkspaceContext implements vscode.Disposable {
if (!(await this.needToAutoGenerateLaunchConfig())) {
return;
}
vscode.window
void vscode.window
.showInformationMessage(
`Launch configurations need to be updated after changing the Swift runtime path. Custom versions of environment variable '${swiftLibraryPathKey()}' may be overridden. Do you want to update?`,
"Update",
Expand All @@ -111,7 +111,7 @@ export class WorkspaceContext implements vscode.Disposable {
if (!(await this.needToAutoGenerateLaunchConfig())) {
return;
}
vscode.window
void vscode.window
.showInformationMessage(
`Launch configurations need to be updated after changing the Swift build path. Do you want to update?`,
"Update",
Expand Down Expand Up @@ -154,7 +154,11 @@ export class WorkspaceContext implements vscode.Disposable {
event.exitCode !== undefined &&
configuration.actionAfterBuildError === "Focus Problems"
) {
vscode.commands.executeCommand("workbench.panel.markers.view.focus");
void vscode.commands
.executeCommand("workbench.panel.markers.view.focus")
.then(() => {
/* Put in worker queue */
});
}
});
const swiftFileWatcher = vscode.workspace.createFileSystemWatcher("**/*.swift");
Expand Down
110 changes: 68 additions & 42 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,75 +106,98 @@ export enum Commands {
*/
export function register(ctx: WorkspaceContext): vscode.Disposable[] {
return [
vscode.commands.registerCommand("swift.generateLaunchConfigurations", () =>
generateLaunchConfigurations(ctx)
vscode.commands.registerCommand(
"swift.generateLaunchConfigurations",
async () => await generateLaunchConfigurations(ctx)
),
vscode.commands.registerCommand("swift.newFile", uri => newSwiftFile(uri)),
vscode.commands.registerCommand(Commands.RESOLVE_DEPENDENCIES, () =>
resolveDependencies(ctx)
vscode.commands.registerCommand("swift.newFile", async uri => await newSwiftFile(uri)),
vscode.commands.registerCommand(
Commands.RESOLVE_DEPENDENCIES,
async () => await resolveDependencies(ctx)
),
vscode.commands.registerCommand(Commands.UPDATE_DEPENDENCIES, () =>
updateDependencies(ctx)
vscode.commands.registerCommand(
Commands.UPDATE_DEPENDENCIES,
async () => await updateDependencies(ctx)
),
vscode.commands.registerCommand(Commands.RUN, target =>
runBuild(ctx, ...unwrapTreeItem(target))
vscode.commands.registerCommand(
Commands.RUN,
async target => await runBuild(ctx, ...unwrapTreeItem(target))
),
vscode.commands.registerCommand(Commands.DEBUG, target =>
debugBuild(ctx, ...unwrapTreeItem(target))
vscode.commands.registerCommand(
Commands.DEBUG,
async target => await debugBuild(ctx, ...unwrapTreeItem(target))
),
vscode.commands.registerCommand(Commands.CLEAN_BUILD, () => cleanBuild(ctx)),
vscode.commands.registerCommand(Commands.RUN_TESTS_MULTIPLE_TIMES, item => {
vscode.commands.registerCommand(Commands.CLEAN_BUILD, async () => await cleanBuild(ctx)),
vscode.commands.registerCommand(Commands.RUN_TESTS_MULTIPLE_TIMES, async (item, count) => {
if (ctx.currentFolder) {
return runTestMultipleTimes(ctx.currentFolder, item, false);
return await runTestMultipleTimes(ctx.currentFolder, item, false, count);
}
}),
vscode.commands.registerCommand("swift.runTestsUntilFailure", item => {
vscode.commands.registerCommand("swift.runTestsUntilFailure", async (item, count) => {
if (ctx.currentFolder) {
return runTestMultipleTimes(ctx.currentFolder, item, true);
return await runTestMultipleTimes(ctx.currentFolder, item, true, count);
}
}),
// Note: switchPlatform is only available on macOS and Swift 6.1 or later
// (gated in `package.json`) because it's the only OS and toolchain combination that
// has Darwin SDKs available and supports code editing with SourceKit-LSP
vscode.commands.registerCommand("swift.switchPlatform", () => switchPlatform(ctx)),
vscode.commands.registerCommand(Commands.RESET_PACKAGE, () => resetPackage(ctx)),
vscode.commands.registerCommand("swift.runScript", () => runSwiftScript(ctx)),
vscode.commands.registerCommand("swift.openPackage", () => {
vscode.commands.registerCommand(
"swift.switchPlatform",
async () => await switchPlatform(ctx)
),
vscode.commands.registerCommand(
Commands.RESET_PACKAGE,
async () => await resetPackage(ctx)
),
vscode.commands.registerCommand("swift.runScript", async () => await runSwiftScript(ctx)),
vscode.commands.registerCommand("swift.openPackage", async () => {
if (ctx.currentFolder) {
return openPackage(ctx.currentFolder.swiftVersion, ctx.currentFolder.folder);
return await openPackage(ctx.currentFolder.swiftVersion, ctx.currentFolder.folder);
}
}),
vscode.commands.registerCommand(Commands.RUN_SNIPPET, target =>
runSnippet(ctx, ...unwrapTreeItem(target))
vscode.commands.registerCommand(
Commands.RUN_SNIPPET,
async target => await runSnippet(ctx, ...unwrapTreeItem(target))
),
vscode.commands.registerCommand(Commands.DEBUG_SNIPPET, target =>
debugSnippet(ctx, ...unwrapTreeItem(target))
vscode.commands.registerCommand(
Commands.DEBUG_SNIPPET,
async target => await debugSnippet(ctx, ...unwrapTreeItem(target))
),
vscode.commands.registerCommand(
Commands.RUN_PLUGIN_TASK,
async () => await runPluginTask()
),
vscode.commands.registerCommand(Commands.RUN_TASK, async name => await runTask(ctx, name)),
vscode.commands.registerCommand(
Commands.RESTART_LSP,
async () => await restartLSPServer(ctx)
),
vscode.commands.registerCommand(Commands.RUN_PLUGIN_TASK, () => runPluginTask()),
vscode.commands.registerCommand(Commands.RUN_TASK, name => runTask(ctx, name)),
vscode.commands.registerCommand(Commands.RESTART_LSP, () => restartLSPServer(ctx)),
vscode.commands.registerCommand("swift.reindexProject", () => reindexProject(ctx)),
vscode.commands.registerCommand("swift.insertFunctionComment", () =>
insertFunctionComment(ctx)
vscode.commands.registerCommand(
"swift.reindexProject",
async () => await reindexProject(ctx)
),
vscode.commands.registerCommand(
"swift.insertFunctionComment",
async () => await insertFunctionComment(ctx)
),
vscode.commands.registerCommand(Commands.USE_LOCAL_DEPENDENCY, (item, dep) => {
vscode.commands.registerCommand(Commands.USE_LOCAL_DEPENDENCY, async (item, dep) => {
if (item instanceof PackageNode) {
return useLocalDependency(item.name, ctx, dep);
return await useLocalDependency(item.name, ctx, dep);
}
}),
vscode.commands.registerCommand("swift.editDependency", item => {
vscode.commands.registerCommand("swift.editDependency", async item => {
if (item instanceof PackageNode) {
return editDependency(item.name, ctx);
return await editDependency(item.name, ctx);
}
}),
vscode.commands.registerCommand(Commands.UNEDIT_DEPENDENCY, item => {
vscode.commands.registerCommand(Commands.UNEDIT_DEPENDENCY, async item => {
if (item instanceof PackageNode) {
return uneditDependency(item.name, ctx);
return await uneditDependency(item.name, ctx);
}
}),
vscode.commands.registerCommand("swift.openInWorkspace", item => {
vscode.commands.registerCommand("swift.openInWorkspace", async item => {
if (item instanceof PackageNode) {
return openInWorkspace(item);
return await openInWorkspace(item);
}
}),
vscode.commands.registerCommand("swift.openExternal", item => {
Expand All @@ -186,7 +209,10 @@ export function register(ctx: WorkspaceContext): vscode.Disposable[] {
vscode.commands.registerCommand("swift.clearDiagnosticsCollection", () =>
ctx.diagnostics.clear()
),
vscode.commands.registerCommand("swift.captureDiagnostics", () => captureDiagnostics(ctx)),
vscode.commands.registerCommand(
"swift.captureDiagnostics",
async () => await captureDiagnostics(ctx)
),
vscode.commands.registerCommand(
Commands.RUN_ALL_TESTS_PARALLEL,
async item => await runAllTests(ctx, TestKind.parallel, ...unwrapTreeItem(item))
Expand Down Expand Up @@ -216,9 +242,9 @@ export function register(ctx: WorkspaceContext): vscode.Disposable[] {
vscode.commands.registerCommand("swift.openEducationalNote", uri =>
openEducationalNote(uri)
),
vscode.commands.registerCommand(Commands.OPEN_MANIFEST, (uri: vscode.Uri) => {
vscode.commands.registerCommand(Commands.OPEN_MANIFEST, async (uri: vscode.Uri) => {
const packagePath = path.join(uri.fsPath, "Package.swift");
vscode.commands.executeCommand("vscode.open", vscode.Uri.file(packagePath));
await vscode.commands.executeCommand("vscode.open", vscode.Uri.file(packagePath));
}),
vscode.commands.registerCommand("swift.openDocumentation", () => openDocumentation()),
];
Expand Down
6 changes: 3 additions & 3 deletions src/commands/captureDiagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export async function captureDiagnostics(
await showCapturedDiagnosticsResults(diagnosticsDir);
}
} catch (error) {
vscode.window.showErrorMessage(`Unable to capture diagnostic logs: ${error}`);
void vscode.window.showErrorMessage(`Unable to capture diagnostic logs: ${error}`);
}
}

Expand Down Expand Up @@ -149,12 +149,12 @@ async function showCapturedDiagnosticsResults(diagnosticsDir: string) {
copyPath
);
if (result === copyPath) {
vscode.env.clipboard.writeText(diagnosticsDir);
await vscode.env.clipboard.writeText(diagnosticsDir);
} else if (result === showInFinderButton) {
exec(showDirectoryCommand(diagnosticsDir), error => {
// Opening the explorer on windows returns an exit code of 1 despite opening successfully.
if (error && process.platform !== "win32") {
vscode.window.showErrorMessage(
void vscode.window.showErrorMessage(
`Failed to open ${showCommandType()}: ${error.message}`
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/createNewProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function createNewProject(toolchain: SwiftToolchain | undefined): P
// activated. As such, we also have to allow this command to run when no workspace is
// active. Show an error to the user if the command is unavailable.
if (!toolchain.swiftVersion.isGreaterThanOrEqual(new Version(5, 8, 0))) {
vscode.window.showErrorMessage(
void vscode.window.showErrorMessage(
"Creating a new swift project is only available starting in swift version 5.8.0."
);
return;
Expand Down Expand Up @@ -180,6 +180,6 @@ export async function createNewProject(toolchain: SwiftToolchain | undefined): P
});
} else if (action === "addToWorkspace") {
const index = vscode.workspace.workspaceFolders?.length ?? 0;
await vscode.workspace.updateWorkspaceFolders(index, 0, { uri: projectUri });
vscode.workspace.updateWorkspaceFolders(index, 0, { uri: projectUri });
}
}
2 changes: 1 addition & 1 deletion src/commands/dependencies/unedit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async function uneditFolderDependency(
await uneditFolderDependency(folder, identifier, ctx, ["--force"]);
} else {
ctx.outputChannel.log(execError.stderr, folder.name);
vscode.window.showErrorMessage(`${execError.stderr}`);
void vscode.window.showErrorMessage(`${execError.stderr}`);
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/newFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function newSwiftFile(
await vscode.languages.setTextDocumentLanguage(document, "swift");
await vscode.window.showTextDocument(document);
} catch (err) {
vscode.window.showErrorMessage(`Failed to create ${targetUri.fsPath}`);
void vscode.window.showErrorMessage(`Failed to create ${targetUri.fsPath}`);
}
} else {
// If no path is supplied then open an untitled editor w/ Swift language type
Expand Down
2 changes: 1 addition & 1 deletion src/commands/openInExternalEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { PackageNode } from "../ui/ProjectPanelProvider";
export function openInExternalEditor(packageNode: PackageNode) {
try {
const uri = vscode.Uri.parse(packageNode.location, true);
vscode.env.openExternal(uri);
void vscode.env.openExternal(uri);
} catch {
// ignore error
}
Expand Down
Loading
Loading