Skip to content

Add Swiftly toolchain management #1717

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

roulpriya
Copy link
Contributor

Description

  • Refactored Swiftly code from toolchain.ts to swiftly.ts
  • Added list-available with json output

Issue: To be created

Tasks

  • Required tests have been written
  • Documentation has been updated
  • Added an entry to CHANGELOG.md if applicable

Copy link
Member

@matthewbastien matthewbastien left a comment

Choose a reason for hiding this comment

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

Thanks! Just a few things to clean up and a question about the failure paths for swiftlyToolchain().

} catch (err: unknown) {
const error = err as ExecFileError;
// Its possible the toolchain in .swift-version is misconfigured or doesn't exist.
void vscode.window.showErrorMessage(`${error.stderr}`);
Copy link
Member

Choose a reason for hiding this comment

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

This seems like something we should be logging and then show a better error message to the user. Something like "Failed to load toolchain from Swiftly: ${error.stderr}".

What are the possible error messages from Swiftly here? Asking because I'm not sure how well VS Code notifications deal with newlines and such.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will add the suggested line.

What are the possible error messages from Swiftly here? Asking because I'm not sure how well VS Code notifications deal with newlines and such.

I think toolchain not found

Copy link
Member

Choose a reason for hiding this comment

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

Can we also log it to the output channel? You'll need to pass it in kind of like how some of the static functions in SwiftToolchain do it.

.filter((toolchain): toolchain is string => typeof toolchain === "string")
.map(toolchain => path.join(swiftlyHomeDir, "toolchains", toolchain));
} catch (error) {
throw new Error("Failed to retrieve Swiftly installations from disk.");
Copy link
Member

Choose a reason for hiding this comment

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

Should probably be logging the original error here rather than swallowing it entirely. Either that or append the message here with ${error.message}.

Copy link
Member

Choose a reason for hiding this comment

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

Can we also log it to the output channel? You'll need to pass it in kind of like how some of the static functions in SwiftToolchain do it.

Copy link
Member

@matthewbastien matthewbastien left a comment

Choose a reason for hiding this comment

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

Whoops. Meant to request changes, not approve.

@roulpriya roulpriya force-pushed the list-available-toolchain branch from 5a07f8b to 68790c8 Compare July 16, 2025 13:04
@roulpriya roulpriya marked this pull request as ready for review July 16, 2025 17:49
});

test("should return empty array when platform is not supported", async () => {
const originalPlatform = process.platform;
Copy link
Member

Choose a reason for hiding this comment

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

We have another utility for this one:

import { mockGlobalValue } from "../MockUtils";

suite("Test Suite", () => {
    const platformMock = mockGlobalValue(process, "platform");
 
    test("test case", () => {
        platformMock.setValue("linux");
    });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants