Skip to content

Commit d9a6fe9

Browse files
committed
Add more tests
1 parent 0af87c8 commit d9a6fe9

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

test/unit-tests/sourcekit-lsp/LanguageClientManager.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,25 @@ suite("LanguageClientManager Suite", () => {
177177
expect(languageClientMock.start).to.have.been.calledOnce;
178178
});
179179

180+
test("launches SourceKit-LSP on startup with swiftSDK", async () => {
181+
mockedConfig.swiftSDK = "arm64-apple-ios";
182+
183+
const sut = new LanguageClientManager(instance(mockedWorkspace));
184+
await waitForReturnedPromises(languageClientMock.start);
185+
186+
expect(sut.state).to.equal(State.Running);
187+
expect(mockedLangClientModule.LanguageClient).to.have.been.calledOnceWith(
188+
/* id */ match.string,
189+
/* name */ match.string,
190+
/* serverOptions */ match.has("command", "/path/to/toolchain/bin/sourcekit-lsp"),
191+
/* clientOptions */ match.hasNested(
192+
"initializationOptions.swiftPM.swiftSDK",
193+
"arm64-apple-ios"
194+
)
195+
);
196+
expect(languageClientMock.start).to.have.been.calledOnce;
197+
});
198+
180199
test("notifies SourceKit-LSP of WorkspaceFolder changes", async () => {
181200
const folder1 = mockObject<FolderContext>({
182201
isRootFolder: false,

test/unit-tests/toolchain/BuildFlags.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ suite("BuildFlags Test Suite", () => {
7878

7979
suite("swiftpmSDKFlags", () => {
8080
const sdkConfig = mockGlobalValue(configuration, "sdk");
81+
const swiftSDKConfig = mockGlobalValue(configuration, "swiftSDK");
8182

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

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

97+
test("configuration provided for swiftSDK", () => {
98+
swiftSDKConfig.setValue("arm64-apple-ios");
99+
expect(buildFlags.swiftpmSDKFlags()).to.deep.equal(["--swift-sdk", "arm64-apple-ios"]);
100+
});
101+
102+
test("configuration provided for swiftSDK and sdk", () => {
103+
sdkConfig.setValue("/some/other/full/test/path");
104+
swiftSDKConfig.setValue("arm64-apple-ios");
105+
expect(buildFlags.swiftpmSDKFlags()).to.deep.equal([
106+
"--sdk",
107+
"/some/other/full/test/path",
108+
"--swift-sdk",
109+
"arm64-apple-ios",
110+
]);
111+
});
112+
95113
test("include target", () => {
96114
sdkConfig.setValue("/some/other/full/test/path/WatchOS.sdk");
97115
expect(buildFlags.swiftpmSDKFlags()).to.deep.equal([

0 commit comments

Comments
 (0)