|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the VS Code Swift open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2024 the VS Code Swift project authors |
| 6 | +// Licensed under Apache License v2.0 |
| 7 | +// |
| 8 | +// See LICENSE.txt for license information |
| 9 | +// See CONTRIBUTORS.txt for the list of VS Code Swift project authors |
| 10 | +// |
| 11 | +// SPDX-License-Identifier: Apache-2.0 |
| 12 | +// |
| 13 | +//===----------------------------------------------------------------------===// |
| 14 | + |
| 15 | +import { expect } from "chai"; |
| 16 | +import { getLLDBLibPath, getLldbProcess } from "../../../src/debugger/lldb"; |
| 17 | +import { globalWorkspaceContextPromise } from "../extension.test"; |
| 18 | +import { WorkspaceContext } from "../../../src/WorkspaceContext"; |
| 19 | + |
| 20 | +suite("lldb contract test suite", () => { |
| 21 | + let workspaceContext: WorkspaceContext; |
| 22 | + |
| 23 | + suiteSetup(async () => { |
| 24 | + workspaceContext = await globalWorkspaceContextPromise; |
| 25 | + }); |
| 26 | + |
| 27 | + test("getLldbProcess Contract Test, make sure the command returns", async () => { |
| 28 | + const result = await getLldbProcess(workspaceContext); |
| 29 | + |
| 30 | + // Assumption: machine will always return some process |
| 31 | + expect(result).to.be.an("array"); |
| 32 | + |
| 33 | + // If result is an array, assert that each element has a pid and label |
| 34 | + result?.forEach(item => { |
| 35 | + expect(item).to.have.property("pid").that.is.a("number"); |
| 36 | + expect(item).to.have.property("label").that.is.a("string"); |
| 37 | + }); |
| 38 | + }); |
| 39 | + |
| 40 | + test("getLLDBLibPath Contract Test, make sure we can find lib LLDB", async () => { |
| 41 | + const libPath = await getLLDBLibPath(workspaceContext.toolchain); |
| 42 | + |
| 43 | + // Check the result for various platforms |
| 44 | + if (process.platform === "linux") { |
| 45 | + expect(libPath.success).to.match(/liblldb.*\.so.*/); // Matches .so file pattern |
| 46 | + } else if (process.platform === "darwin") { |
| 47 | + expect(libPath.success).to.match(/liblldb\..*dylib|LLDB/); // Matches .dylib or LLDB |
| 48 | + } else if (process.platform === "win32") { |
| 49 | + expect(libPath.success).to.match(/liblldb\.dll/); // Matches .dll for Windows |
| 50 | + } else { |
| 51 | + // In other platforms, the path hint should be returned directly |
| 52 | + expect(libPath.success).to.be.a("string"); |
| 53 | + } |
| 54 | + }); |
| 55 | +}); |
0 commit comments