-
Notifications
You must be signed in to change notification settings - Fork 511
Fix path regressions and cover with tests #3570
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
@TylerLeonhardt Pinged you on Teams, if you have any suggestions on how to assert what seemed like such a simple thing. But sadly the VS Code API does not give me meaningful return values for |
WIP test file with some of those attemps: // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import * as assert from "assert";
import * as vscode from "vscode";
import { before, beforeEach, afterEach } from "mocha";
import { ExamplesFeature } from "../../src/features/Examples";
// tslint:disable-next-line: no-var-requires
const packageJSON: any = require("../../../package.json");
const extensionId = `${packageJSON.publisher}.${packageJSON.name}`;
let extension: any;
suite("Startup behavior", () => {
before(async () => {
extension = vscode.extensions.getExtension(extensionId);
if (!extension.isActive) {
await extension.activate();
}
});
test("Should know where the examples are", () => {
// const x = new ExamplesFeature() as any;
// const path = x.examplesPath as string;
// assert(path.endsWith(`extensions/${extensionId}/examples`));
vscode.commands.getCommands()
const x = extension.commandRegistrations[0] as any;
const path = x.examplesPath as string;
assert(path.endsWith(`extensions/${extensionId}/examples`));
})
// test("The examples folder can be opened", async () => {
// await vscode.commands.executeCommand("PowerShell.OpenExamplesFolder");
// });
// test("The session folder is created in the right place", async () => {
// })
}); |
Hey @rjmholt and @JustinGrote look at that, regression tests! |
65f2c6e
to
f118337
Compare
Some strange CI issues with PowerShell 5.1:
|
f118337
to
b3662b5
Compare
I think I fixed the CI issues. It was unfortunately due to Windows PowerShell bundling Pester 3.0.4 which is ancient. |
dd6e1b3
to
bedd06b
Compare
62e9d4f
to
3697572
Compare
@rjmholt I think that this test is demonstrating the very real problems of our debuggers' reliability. |
45bd1c0
to
4cd0baa
Compare
Going to rebase and see if this is still failing regularly... |
This are hard to get right, and harder to test.
Cleans up some repetitive code and makes tests more stable.
The `before` and `after` etc. are for BDD (e.g. `describe` and `it`), but we're using TDD (e.g. `suite` and `test`). I think they're just aliases of each other, but let's be correct.
So that they're always run as expected, leaving the state clean for the next test regardless of ordering.
Save and restore the user's theme, which was annoying when running the tests via Code's debugger. Don't use the default theme "Dark+" so that the setting is actually propogated.
4cd0baa
to
f1519f8
Compare
Hmm...things are looking up today! |
@rjmholt whacha think? This has passed four times in a row now, the inconsistency seems gone. I don't really know what changed except perhaps a better mitigation of the race condition through a forced (and rather long) sleep. |
Repeating tests again for safety's sake! |
This is hard to get right, and harder to test.
So the path on disk for all the code (because of bundling) is:
Hence,
path.resolve(__dirname, "../")
moves us to:Because
__dirname
is the folder containingmain.js
(that is,out
). And that's what has:But wow, getting a test written to cover this is nigh-impossible due to the design.
When I bundled I was relying on successful compilation and tests, since there were a number of paths. I shouldn't have solely relied on that. I spent the better part of today trying to write a test to cover this, and took three different approaches just to check that the path used for
OpenExamplesFolder
is correct. But I cannot see how to test it sufficiently.