vscode
Зеркало из https://github.com/microsoft/vscode
/
.vscode-test.js
136 строк · 4.6 Кб
1/*---------------------------------------------------------------------------------------------
2* Copyright (c) Microsoft Corporation. All rights reserved.
3* Licensed under the MIT License. See License.txt in the project root for license information.
4*--------------------------------------------------------------------------------------------*/
5
6//@ts-check
7
8import { createRequire } from 'node:module';9import { fileURLToPath } from 'url';10import * as path from 'path';11import * as os from 'os';12
13const require = createRequire(import.meta.url);14const __dirname = path.dirname(fileURLToPath(import.meta.url));15
16const { defineConfig } = require('@vscode/test-cli');17
18/**
19* A list of extension folders who have opted into tests, or configuration objects.
20* Edit me to add more!
21*
22* @type {Array<Partial<import("@vscode/test-cli").TestConfiguration> & { label: string }>}
23*/
24const extensions = [25{26label: 'markdown-language-features',27workspaceFolder: `extensions/markdown-language-features/test-workspace`,28mocha: { timeout: 60_000 }29},30{31label: 'ipynb',32workspaceFolder: path.join(os.tmpdir(), `ipynb-${Math.floor(Math.random() * 100000)}`),33mocha: { timeout: 60_000 }34},35{36label: 'notebook-renderers',37workspaceFolder: path.join(os.tmpdir(), `nbout-${Math.floor(Math.random() * 100000)}`),38mocha: { timeout: 60_000 }39},40{41label: 'vscode-colorize-tests',42workspaceFolder: `extensions/vscode-colorize-tests/test`,43mocha: { timeout: 60_000 }44},45{46label: 'terminal-suggest',47workspaceFolder: path.join(os.tmpdir(), `terminal-suggest-${Math.floor(Math.random() * 100000)}`),48mocha: { timeout: 60_000 }49},50{51label: 'vscode-colorize-perf-tests',52workspaceFolder: `extensions/vscode-colorize-perf-tests/test`,53mocha: { timeout: 6000_000 }54},55{56label: 'configuration-editing',57workspaceFolder: path.join(os.tmpdir(), `confeditout-${Math.floor(Math.random() * 100000)}`),58mocha: { timeout: 60_000 }59},60{61label: 'github-authentication',62workspaceFolder: path.join(os.tmpdir(), `msft-auth-${Math.floor(Math.random() * 100000)}`),63mocha: { timeout: 60_000 }64},65{66label: 'microsoft-authentication',67mocha: { timeout: 60_000 }68},69{70label: 'vscode-api-tests-folder',71extensionDevelopmentPath: `extensions/vscode-api-tests`,72workspaceFolder: `extensions/vscode-api-tests/testWorkspace`,73mocha: { timeout: 60_000 },74files: 'extensions/vscode-api-tests/out/singlefolder-tests/**/*.test.js',75},76{77label: 'vscode-api-tests-workspace',78extensionDevelopmentPath: `extensions/vscode-api-tests`,79workspaceFolder: `extensions/vscode-api-tests/testworkspace.code-workspace`,80mocha: { timeout: 60_000 },81files: 'extensions/vscode-api-tests/out/workspace-tests/**/*.test.js',82}83];84
85
86const defaultLaunchArgs = process.env.API_TESTS_EXTRA_ARGS?.split(' ') || [87'--disable-telemetry', '--skip-welcome', '--skip-release-notes', `--crash-reporter-directory=${__dirname}/.build/crashes`, `--logsPath=${__dirname}/.build/logs/integration-tests`, '--no-cached-data', '--disable-updates', '--use-inmemory-secretstorage', '--disable-extensions', '--disable-workspace-trust'88];89
90const config = defineConfig(extensions.map(extension => {91/** @type {import('@vscode/test-cli').TestConfiguration} */92const config = {93platform: 'desktop',94files: `extensions/${extension.label}/out/**/*.test.js`,95extensionDevelopmentPath: `extensions/${extension.label}`,96...extension,97};98
99config.mocha ??= {};100if (process.env.BUILD_ARTIFACTSTAGINGDIRECTORY) {101let suite = '';102if (process.env.VSCODE_BROWSER) {103suite = `${process.env.VSCODE_BROWSER} Browser Integration ${config.label} tests`;104} else if (process.env.REMOTE_VSCODE) {105suite = `Remote Integration ${config.label} tests`;106} else {107suite = `Integration ${config.label} tests`;108}109
110config.mocha.reporter = 'mocha-multi-reporters';111config.mocha.reporterOptions = {112reporterEnabled: 'spec, mocha-junit-reporter',113mochaJunitReporterReporterOptions: {114testsuitesTitle: `${suite} ${process.platform}`,115mochaFile: path.join(process.env.BUILD_ARTIFACTSTAGINGDIRECTORY, `test-results/${process.platform}-${process.arch}-${suite.toLowerCase().replace(/[^\w]/g, '-')}-results.xml`)116}117};118}119
120if (!config.platform || config.platform === 'desktop') {121config.launchArgs = defaultLaunchArgs;122config.useInstallation = {123fromPath: process.env.INTEGRATION_TEST_ELECTRON_PATH || `${__dirname}/scripts/code.${process.platform === 'win32' ? 'bat' : 'sh'}`,124};125config.env = {126...config.env,127VSCODE_SKIP_PRELAUNCH: '1',128};129} else {130// web configs not supported, yet131}132
133return config;134}));135
136export default config;137