Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kabiroberai committed Nov 2, 2024
1 parent 2a77d75 commit b0d8aa3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/unit-tests/sourcekit-lsp/LanguageClientManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,25 @@ suite("LanguageClientManager Suite", () => {
expect(languageClientMock.start).to.have.been.calledOnce;
});

test("launches SourceKit-LSP on startup with swiftSDK", async () => {
mockedConfig.swiftSDK = "arm64-apple-ios";

const sut = new LanguageClientManager(instance(mockedWorkspace));
await waitForReturnedPromises(languageClientMock.start);

expect(sut.state).to.equal(State.Running);
expect(mockedLangClientModule.LanguageClient).to.have.been.calledOnceWith(
/* id */ match.string,
/* name */ match.string,
/* serverOptions */ match.has("command", "/path/to/toolchain/bin/sourcekit-lsp"),
/* clientOptions */ match.hasNested(
"initializationOptions.swiftPM.swiftSDK",
"arm64-apple-ios"
)
);
expect(languageClientMock.start).to.have.been.calledOnce;
});

test("notifies SourceKit-LSP of WorkspaceFolder changes", async () => {
const folder1 = mockObject<FolderContext>({
isRootFolder: false,
Expand Down
18 changes: 18 additions & 0 deletions test/unit-tests/toolchain/BuildFlags.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,11 @@ suite("BuildFlags Test Suite", () => {

suite("swiftpmSDKFlags", () => {
const sdkConfig = mockGlobalValue(configuration, "sdk");
const swiftSDKConfig = mockGlobalValue(configuration, "swiftSDK");

test("no configuration provided", async () => {
sdkConfig.setValue("");
swiftSDKConfig.setValue("");
expect(buildFlags.swiftpmSDKFlags()).to.be.an("array").that.is.empty;
});

Expand All @@ -92,6 +94,22 @@ suite("BuildFlags Test Suite", () => {
]);
});

test("configuration provided for swiftSDK", () => {
swiftSDKConfig.setValue("arm64-apple-ios");
expect(buildFlags.swiftpmSDKFlags()).to.deep.equal(["--swift-sdk", "arm64-apple-ios"]);
});

test("configuration provided for swiftSDK and sdk", () => {
sdkConfig.setValue("/some/other/full/test/path");
swiftSDKConfig.setValue("arm64-apple-ios");
expect(buildFlags.swiftpmSDKFlags()).to.deep.equal([
"--sdk",
"/some/other/full/test/path",
"--swift-sdk",
"arm64-apple-ios",
]);
});

test("include target", () => {
sdkConfig.setValue("/some/other/full/test/path/WatchOS.sdk");
expect(buildFlags.swiftpmSDKFlags()).to.deep.equal([
Expand Down

0 comments on commit b0d8aa3

Please sign in to comment.