Skip to content

Update test runner #3506

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

Merged
merged 5 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
414 changes: 226 additions & 188 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"@types/sinon": "~10.0.2",
"@types/uuid": "~8.3.1",
"@types/vscode": "~1.53.0",
"@vscode/test-electron": "~1.6.2",
"mocha": "~9.0.3",
"mocha-junit-reporter": "~2.0.0",
"mocha-multi-reporters": "~1.5.1",
Expand All @@ -72,8 +73,7 @@
"sinon": "~11.1.2",
"tslint": "~6.1.3",
"typescript": "~4.3.5",
"vsce": "~1.96.1",
"vscode-test": "~1.6.1"
"vsce": "~1.96.1"
},
"extensionDependencies": [
"vscode.powershell"
Expand Down
2 changes: 1 addition & 1 deletion test/platform.test.ts → test/core/platform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import mockFS = require("mock-fs");
import FileSystem = require("mock-fs/lib/filesystem");
import * as path from "path";
import * as sinon from "sinon";
import * as platform from "../src/platform";
import * as platform from "../../src/platform";

/**
* Describes a platform on which the PowerShell extension should work,
Expand Down
2 changes: 1 addition & 1 deletion test/settings.test.ts → test/core/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import * as assert from "assert";
import * as vscode from "vscode";
import Settings = require("../src/settings");
import Settings = require("../../src/settings");

suite("Settings module", () => {
test("Settings load without error", () => {
Expand Down
8 changes: 0 additions & 8 deletions test/fixtures/.gitattributes

This file was deleted.

17 changes: 11 additions & 6 deletions test/testRunner.ts → test/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import * as glob from "glob";
import * as Mocha from "mocha";
// NOTE: This code is borrowed under permission from:
// https://github.com/microsoft/vscode-extension-samples/tree/main/helloworld-test-sample/src/test

import * as path from "path";
import * as Mocha from "mocha";
import * as glob from "glob";

export function run(): Promise<void> {
// Create the mocha test
const mocha = new Mocha({
ui: "tdd", // the TDD UI is being used in extension.test.ts (suite, test, etc.)
ui: "tdd",
color: !process.env.TF_BUILD, // colored output from test results
reporter: "mocha-multi-reporters",
timeout: 5000,
Expand All @@ -23,24 +26,26 @@ export function run(): Promise<void> {
const testsRoot = path.resolve(__dirname, "..");

return new Promise((c, e) => {
glob("**/**.test.js", { cwd: testsRoot }, (err: any, files: any[]) => {
glob("**/**.test.js", { cwd: testsRoot }, (err, files) => {
if (err) {
return e(err);
}

// Add files to the test suite
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));

try {
// Run the mocha test
mocha.run((failures) => {
mocha.run(failures => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
// tslint:disable-next-line:no-console
console.error(err);
e(err);
}
});
Expand Down
25 changes: 10 additions & 15 deletions test/runTests.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import * as path from "path";
// NOTE: This code is borrowed under permission from:
// https://github.com/microsoft/vscode-extension-samples/tree/main/helloworld-test-sample/src/test

import { runTests } from "vscode-test";
import * as path from "path";

// tslint:disable-next-line: no-var-requires
const PackageJSON: any = require("../../package.json");
const testExtensionId = `${PackageJSON.publisher}.${PackageJSON.name}`;
import { runTests } from "@vscode/test-electron";

async function main() {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, "../../");

// The path to the extension test runner script
// The path to the extension test script
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, "./testRunner");
const extensionTestsPath = path.resolve(__dirname, "./index");

// Download VS Code, unzip it and run the integration test from the local directory.
// Download VS Code, unzip it and run the integration test
await runTests({
extensionDevelopmentPath,
extensionTestsPath,
launchArgs: [
"--disable-extensions",
"--enable-proposed-api", testExtensionId,
"./test"
],
launchArgs: ["--disable-extensions", "./test"],
// This is necessary because the tests fail if more than once
// instance of Code is running.
version: "insiders"
});
} catch (err) {
// tslint:disable-next-line:no-console
console.error(err);
// tslint:disable-next-line:no-console
console.error("Failed to run tests");
process.exit(1);
Expand Down
20 changes: 0 additions & 20 deletions test/test_utils.ts

This file was deleted.