Skip to content

Conversation

@michael-weng
Copy link
Contributor

Cover all the error return cases.

Issue: #1023

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");
Copy link
Contributor

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'

Copy link
Contributor Author

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", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

});

teardown(() => {
mockFindLibLLDB.reset();
Copy link
Contributor

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

Copy link
Contributor Author

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();
Copy link
Contributor

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(...)

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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 () {
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@award999 award999 self-requested a review October 4, 2024 14:16
Copy link
Contributor

@award999 award999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@matthewbastien matthewbastien merged commit d8e7670 into swiftlang:main Oct 4, 2024
@michael-weng michael-weng deleted the lldb_utest branch October 4, 2024 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants