-
Notifications
You must be signed in to change notification settings - Fork 80
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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()
.
src/toolchain/swiftly.ts
Outdated
} 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}`); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
src/toolchain/swiftly.ts
Outdated
.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."); |
There was a problem hiding this comment.
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}
.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
5a07f8b
to
68790c8
Compare
}); | ||
|
||
test("should return empty array when platform is not supported", async () => { | ||
const originalPlatform = process.platform; |
There was a problem hiding this comment.
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");
});
});
Description
Issue: To be created
Tasks