| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- "use strict";
- /*---------------------------------------------------------
- * Copyright (C) Microsoft Corporation. All rights reserved.
- *--------------------------------------------------------*/
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.run = run;
- const mocha_1 = __importDefault(require("mocha"));
- async function run() {
- const { mochaOpts, files, preload, colorDefault, } = JSON.parse(process.env.VSCODE_TEST_OPTIONS);
- // Create the mocha test
- const mocha = new mocha_1.default({
- ui: 'tdd',
- color: colorDefault,
- ...mochaOpts,
- });
- const required = [
- ...preload,
- ...ensureArray(mochaOpts.require),
- ].map((f) => require(normalizeCasing(f)));
- // currently `require` only seems to take effect for parallel runs, but remove
- // the option in case it's supported for serial runs in the future since we're
- // handling it ourselves.
- delete mochaOpts.require;
- for (const { mochaGlobalSetup } of required) {
- await mochaGlobalSetup?.();
- }
- for (const file of files) {
- mocha.addFile(normalizeCasing(file));
- }
- await new Promise((resolve, reject) => mocha.run((failures) => failures
- ? reject(failures > 1 ? `${failures} tests failed.` : `${failures} test failed.`)
- : resolve()));
- for (const { mochaGlobalTeardown } of required) {
- await mochaGlobalTeardown?.();
- }
- }
- const normalizeCasing = (path) => {
- // Normalize to lower-case drive letter to avoid path sensitivity in the loader
- // duplicating imports. VS Code normalizes to lower case drive letters in its
- // URIs, so do the same here
- // https://github.com/microsoft/vscode/blob/032c1b75447ade317715c3d2a82c2d9cd3e55dde/src/vs/base/common/uri.ts#L181-L185
- if (process.platform === 'win32' && path.match(/^[A-Z]:/)) {
- return path[0].toLowerCase() + path.slice(1);
- }
- return path;
- };
- const ensureArray = (value) => value ? (Array.isArray(value) ? value : [value]) : [];
|