-
Notifications
You must be signed in to change notification settings - Fork 85
Add unit tests for lldb.ts #1110
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
Conversation
Cover all the error return cases. Issue: swiftlang#1023
| } from "../../MockUtils"; | ||
| import { SwiftToolchain } from "../../../src/toolchain/toolchain"; | ||
| import { WorkspaceContext } from "../../../src/WorkspaceContext"; | ||
| import sinon = require("sinon"); |
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.
import * as sinon from 'sinon'
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.
Done
| import { WorkspaceContext } from "../../../src/WorkspaceContext"; | ||
| import sinon = require("sinon"); | ||
|
|
||
| suite("getLLDBLibPath Tests", () => { |
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.
since there is other functions in the module, lets follow the naming matt outlined https://github.com/swiftlang/vscode-swift/blob/main/docs/contributor/writing-tests-for-vscode-swift.md#writing-unit-tests
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.
Oh I see below you have one suite for each function, it is a common mocha pattern to have 1 top level suite in a module so lldb Unit Test Suite that then has nested suites for each function
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.
Done
| }); | ||
|
|
||
| teardown(() => { | ||
| mockFindLibLLDB.reset(); |
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.
Is setup is recreating each test, shouldn't have to reset
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.
Done
| let result = await lldb.getLLDBLibPath(instance(mockToolchain)); | ||
| expect(result.failure).to.not.equal(undefined); | ||
|
|
||
| mockFindLibLLDB.reset(); |
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 shouldn't need to reset, you can do something like mockFindLibLLDB.onFirstCall().resolves(...)
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.
Done
- make suite nested to adhere to one suite per module convention - clean up some teardown code and remove redundancy in test - fix date in copyright - change to typescript import
|
|
||
| expect(result).to.equal("/path/hint"); | ||
| }); | ||
| // NB(separate itest): contract test with toolchains of various platforms |
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.
question: what does the NB stand for?
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.
| expect(result.failure).to.have.property("message", "Failed to get LLDB"); | ||
| }); | ||
|
|
||
| test("should return failure when execFile throws an error on windows, specific behaviour: return success and failure both undefined", async function () { |
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 is wordy, not sure intent, and seems like we're skipping on windows not should return failure when execFile throws an error on windows
we should make intent more clear
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.
Done
award999
left a comment
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.
LGTM
Cover all the error return cases.
Issue: #1023