2022-05-17 12:15:06 -05:00
|
|
|
import * as path from "path";
|
|
|
|
import * as fs from "fs";
|
2020-05-20 13:03:49 -05:00
|
|
|
|
2022-05-17 12:15:06 -05:00
|
|
|
import { runTests } from "@vscode/test-electron";
|
2020-05-20 13:03:49 -05:00
|
|
|
|
|
|
|
async function main() {
|
2020-05-21 03:34:34 -05:00
|
|
|
// The folder containing the Extension Manifest package.json
|
|
|
|
// Passed to `--extensionDevelopmentPath`
|
2022-05-17 12:15:06 -05:00
|
|
|
const extensionDevelopmentPath = path.resolve(__dirname, "../../");
|
2020-05-21 03:34:34 -05:00
|
|
|
|
|
|
|
// Minimum supported version.
|
2022-05-17 12:15:06 -05:00
|
|
|
const jsonData = fs.readFileSync(path.join(extensionDevelopmentPath, "package.json"));
|
2020-05-21 03:34:34 -05:00
|
|
|
const json = JSON.parse(jsonData.toString());
|
|
|
|
let minimalVersion: string = json.engines.vscode;
|
2022-05-17 12:15:06 -05:00
|
|
|
if (minimalVersion.startsWith("^")) minimalVersion = minimalVersion.slice(1);
|
2020-05-21 03:34:34 -05:00
|
|
|
|
2022-05-11 07:34:43 -05:00
|
|
|
const launchArgs = ["--disable-extensions", extensionDevelopmentPath];
|
2020-05-21 03:34:34 -05:00
|
|
|
|
|
|
|
// All test suites (either unit tests or integration tests) should be in subfolders.
|
2022-05-17 12:15:06 -05:00
|
|
|
const extensionTestsPath = path.resolve(__dirname, "./unit/index");
|
2020-05-21 03:34:34 -05:00
|
|
|
|
|
|
|
// Run tests using the minimal supported version.
|
|
|
|
await runTests({
|
|
|
|
version: minimalVersion,
|
|
|
|
launchArgs,
|
|
|
|
extensionDevelopmentPath,
|
2022-05-17 12:15:06 -05:00
|
|
|
extensionTestsPath,
|
2020-05-21 03:34:34 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
// and the latest one
|
|
|
|
await runTests({
|
2022-05-17 12:15:06 -05:00
|
|
|
version: "stable",
|
2020-05-21 03:34:34 -05:00
|
|
|
launchArgs,
|
|
|
|
extensionDevelopmentPath,
|
2022-05-17 12:15:06 -05:00
|
|
|
extensionTestsPath,
|
2020-05-21 03:34:34 -05:00
|
|
|
});
|
2020-05-20 13:03:49 -05:00
|
|
|
}
|
|
|
|
|
2022-05-17 12:15:06 -05:00
|
|
|
main().catch((err) => {
|
2020-05-21 03:34:34 -05:00
|
|
|
// eslint-disable-next-line no-console
|
2022-05-17 12:15:06 -05:00
|
|
|
console.error("Failed to run tests", err);
|
2020-05-21 03:34:34 -05:00
|
|
|
process.exit(1);
|
|
|
|
});
|