From b0d8aa367a587177d4e6b4b3d4066eaf1a77fb11 Mon Sep 17 00:00:00 2001 From: Kabir Oberai Date: Sat, 2 Nov 2024 19:23:37 -0400 Subject: [PATCH] Add more tests --- .../LanguageClientManager.test.ts | 19 +++++++++++++++++++ test/unit-tests/toolchain/BuildFlags.test.ts | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/test/unit-tests/sourcekit-lsp/LanguageClientManager.test.ts b/test/unit-tests/sourcekit-lsp/LanguageClientManager.test.ts index a1e563862..5eb1993cf 100644 --- a/test/unit-tests/sourcekit-lsp/LanguageClientManager.test.ts +++ b/test/unit-tests/sourcekit-lsp/LanguageClientManager.test.ts @@ -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({ isRootFolder: false, diff --git a/test/unit-tests/toolchain/BuildFlags.test.ts b/test/unit-tests/toolchain/BuildFlags.test.ts index 0c1979546..aba7b7f40 100644 --- a/test/unit-tests/toolchain/BuildFlags.test.ts +++ b/test/unit-tests/toolchain/BuildFlags.test.ts @@ -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; }); @@ -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([