Bring smoketest scripts together (#3370)

This commit is contained in:
Alexandru Dima 2022-10-18 14:20:09 +02:00 коммит произвёл GitHub
Родитель 5d653b2569
Коммит 2b3d8516c6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
15 изменённых файлов: 1546 добавлений и 112 удалений

2
.github/workflows/ci.yml поставляемый
Просмотреть файл

@ -48,7 +48,7 @@ jobs:
run: npm run compile --prefix webpack-plugin
- name: Package using webpack plugin
run: npm run package-for-smoketest --prefix webpack-plugin
run: npm run package-for-smoketest-webpack
- name: Package using esbuild
run: npm run package-for-smoketest-esbuild

1446
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -17,6 +17,8 @@
"pretty-quick": "pretty-quick --staged",
"release": "ts-node ./build/build && ts-node ./build/release",
"simpleserver": "ts-node ./build/simpleserver",
"package-for-smoketest-webpack": "ts-node ./test/smoke/package-webpack",
"package-for-smoketest-webpack-cross-origin": "ts-node ./test/smoke/package-webpack --cross-origin",
"package-for-smoketest-esbuild": "ts-node ./test/smoke/package-esbuild",
"package-for-smoketest-vite": "ts-node ./test/smoke/package-vite",
"smoketest": "node ./test/smoke/runner.js",
@ -38,8 +40,10 @@
"@typescript/vfs": "^1.3.5",
"chai": "^4.3.6",
"clean-css": "^5.2.4",
"css-loader": "^6.7.1",
"esbuild": "^0.14.49",
"esbuild-plugin-alias": "^0.2.1",
"file-loader": "^6.2.0",
"glob": "^7.2.0",
"husky": "^7.0.4",
"jsdom": "^19.0.0",
@ -50,6 +54,7 @@
"prettier": "^2.5.1",
"pretty-quick": "^3.1.3",
"requirejs": "^2.3.6",
"style-loader": "^3.3.1",
"terser": "^5.14.2",
"ts-node": "^10.6.0",
"typedoc": "^0.22.11",
@ -61,6 +66,7 @@
"vscode-languageserver-textdocument": "^1.0.4",
"vscode-languageserver-types": "3.16.0",
"vscode-uri": "3.0.3",
"webpack": "^5.74.0",
"yaserver": "^0.4.0"
}
}

Просмотреть файл

@ -5,11 +5,11 @@
</head>
<body>
<div id="editor-container" style="position: absolute; width: 500px; height: 400px"></div>
<script src="../../release/dev/vs/loader.js"></script>
<script src="../../../release/dev/vs/loader.js"></script>
<script>
require.config({
paths: {
vs: '../../release/dev/vs'
vs: '../../../release/dev/vs'
}
});
require(['vs/editor/editor.main'], () => {

Просмотреть файл

@ -3,4 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
exports.PORT = 8563;
/* keeping TS happy */
exports.__nothing = undefined;
/** @typedef {'chromium'|'firefox'|'webkit'} BrowserKind */
/** @typedef {'amd'|'webpack'|'esbuild'|'vite'} PackagerKind */
/** @typedef {{browser:BrowserKind; packager:PackagerKind; debugTests:boolean; port:number;}} TestInfo */

Просмотреть файл

Просмотреть файл

@ -7,7 +7,7 @@ import * as esbuild from 'esbuild';
import * as path from 'path';
import { removeDir } from '../../build/fs';
removeDir('test/smoke/esbuild/out', (entry) => /esbuild.html$/.test(entry));
removeDir('test/smoke/esbuild/out');
const workerEntryPoints = [
'vs/language/json/json.worker.js',

Просмотреть файл

@ -0,0 +1,56 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import webpack from 'webpack';
import MonacoWebpackPlugin from '../../webpack-plugin/out/index.js';
import * as path from 'path';
const REPO_ROOT = path.join(__dirname, '../../');
const CROSS_ORIGIN_ASSETS = process.argv.includes('--cross-origin');
webpack(
{
mode: 'development',
entry: './index.js',
context: path.join(__dirname, 'webpack'),
output: {
path: path.resolve(REPO_ROOT, 'test/smoke/webpack/out'),
filename: 'app.js',
publicPath: CROSS_ORIGIN_ASSETS
? 'http://localhost:8088/monaco-editor/test/smoke/webpack/out/'
: undefined
},
resolve: {
alias: {
'monaco-editor': path.resolve(REPO_ROOT, 'release')
}
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.ttf$/,
use: ['file-loader']
}
]
},
plugins: [<any>new MonacoWebpackPlugin({
monacoEditorPath: path.resolve(REPO_ROOT, 'release')
})]
},
(err: Error | undefined, stats: webpack.Stats | undefined) => {
if (err) {
console.error(err);
process.exit(1);
}
if (stats && stats.hasErrors()) {
console.log(stats.compilation.errors);
process.exit(1);
}
}
);

Просмотреть файл

@ -9,10 +9,14 @@ const yaserver = require('yaserver');
const http = require('http');
const cp = require('child_process');
const path = require('path');
const { PORT } = require('./common');
const DEBUG_TESTS = process.argv.includes('--debug-tests');
/** @typedef {import('./common').BrowserKind} BrowserKind */
/** @typedef {import('./common').PackagerKind} PackagerKind */
/** @typedef {import('./common').TestInfo} TestInfo */
const DEBUG_TESTS = process.argv.includes('--debug-tests');
const REPO_ROOT = path.join(__dirname, '../../');
const PORT = 8563;
yaserver
.createServer({
@ -37,7 +41,7 @@ yaserver
async function runTests() {
// uncomment to shortcircuit and run a specific combo
// await runTest('webpack', 'chromium'); return;
/** @type {('amd'|'webpack'|'esbuild'|'vite')[]} */
/** @type {PackagerKind[]} */
const testTypes = ['amd', 'webpack', 'esbuild', 'vite'];
for (const type of testTypes) {
@ -48,16 +52,20 @@ async function runTests() {
}
/**
* @param {'amd'|'webpack'|'esbuild'|'vite'} type
* @param {'chromium'|'firefox'|'webkit'} browser
* @param {PackagerKind} packager
* @param {BrowserKind} browser
* @returns
*/
function runTest(type, browser) {
function runTest(packager, browser) {
return new Promise((resolve, reject) => {
const env = { BROWSER: browser, TESTS_TYPE: type, ...process.env };
if (DEBUG_TESTS) {
env['DEBUG_TESTS'] = 'true';
}
/** @type TestInfo */
const testInfo = {
browser,
packager,
debugTests: DEBUG_TESTS,
port: PORT
};
const env = { MONACO_TEST_INFO: JSON.stringify(testInfo), ...process.env };
const proc = cp.spawn(
'node',
[

Просмотреть файл

@ -7,21 +7,23 @@
const playwright = require('playwright');
const { assert } = require('chai');
const { PORT } = require('./common');
const browserType = process.env.BROWSER || 'chromium';
const DEBUG_TESTS = Boolean(process.env.DEBUG_TESTS || false);
const TESTS_TYPE = process.env.TESTS_TYPE || 'amd';
/** @typedef {import('./common').BrowserKind} BrowserKind */
/** @typedef {import('./common').PackagerKind} PackagerKind */
/** @typedef {import('./common').TestInfo} TestInfo */
/** @type TestInfo */
const testInfo = JSON.parse(process.env.MONACO_TEST_INFO || '');
const URLS = {
amd: `http://127.0.0.1:${PORT}/test/smoke/amd.html`,
webpack: `http://127.0.0.1:${PORT}/test/smoke/webpack/webpack.html`,
esbuild: `http://127.0.0.1:${PORT}/test/smoke/esbuild/esbuild.html`,
vite: `http://127.0.0.1:${PORT}/test/smoke/vite/dist/index.html`
amd: `http://127.0.0.1:${testInfo.port}/test/smoke/amd/index.html`,
webpack: `http://127.0.0.1:${testInfo.port}/test/smoke/webpack/index.html`,
esbuild: `http://127.0.0.1:${testInfo.port}/test/smoke/esbuild/index.html`,
vite: `http://127.0.0.1:${testInfo.port}/test/smoke/vite/dist/index.html`
};
const URL = URLS[TESTS_TYPE];
const URL = URLS[testInfo.packager];
suite(`Smoke Test '${TESTS_TYPE}' on '${browserType}'`, () => {
suite(`Smoke Test '${testInfo.packager}' on '${testInfo.browser}'`, () => {
/** @type {playwright.Browser} */
let browser;
@ -29,10 +31,10 @@ suite(`Smoke Test '${TESTS_TYPE}' on '${browserType}'`, () => {
let page;
suiteSetup(async () => {
browser = await playwright[browserType].launch({
headless: !DEBUG_TESTS,
devtools: DEBUG_TESTS && browserType === 'chromium'
// slowMo: DEBUG_TESTS ? 2000 : 0
browser = await playwright[testInfo.browser].launch({
headless: !testInfo.debugTests,
devtools: testInfo.debugTests && testInfo.browser === 'chromium'
// slowMo: testInfo.debugTests ? 2000 : 0
});
});

Просмотреть файл

Просмотреть файл

Просмотреть файл

@ -5,8 +5,6 @@
"main": "out/index.js",
"typings": "./out/index.d.ts",
"scripts": {
"package-for-smoketest": "node ./node_modules/webpack/bin/webpack.js --config smoketest/webpack.config.js --progress",
"smoketest-cross-origin": "node ./node_modules/webpack/bin/webpack.js --config smoketest/webpack-cross-origin.config.js --progress",
"watch": "tsc -w -p tsconfig.json",
"compile": "tsc -p tsconfig.json",
"import-editor": "node ./scripts/import-editor.js",

Просмотреть файл

@ -1,39 +0,0 @@
const MonacoWebpackPlugin = require('../out/index.js');
const path = require('path');
const ASSET_PATH = 'http://localhost:8088/monaco-editor/test/smoke/webpack/out/';
const REPO_ROOT = path.join(__dirname, '../../');
module.exports = {
mode: 'development',
entry: './index.js',
context: __dirname,
output: {
path: path.resolve(REPO_ROOT, 'test/smoke/webpack/out'),
filename: 'app.js',
publicPath: ASSET_PATH
},
resolve: {
alias: {
'monaco-editor': path.resolve(REPO_ROOT, 'release')
}
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.ttf$/,
use: ['file-loader']
}
]
},
plugins: [
new MonacoWebpackPlugin({
monacoEditorPath: path.resolve(REPO_ROOT, 'release')
})
]
};

Просмотреть файл

@ -1,36 +0,0 @@
const MonacoWebpackPlugin = require('../out/index.js');
const path = require('path');
const REPO_ROOT = path.join(__dirname, '../../');
module.exports = {
mode: 'development',
entry: './index.js',
context: __dirname,
output: {
path: path.resolve(REPO_ROOT, 'test/smoke/webpack/out'),
filename: 'app.js'
},
resolve: {
alias: {
'monaco-editor': path.resolve(REPO_ROOT, 'release')
}
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.ttf$/,
use: ['file-loader']
}
]
},
plugins: [
new MonacoWebpackPlugin({
monacoEditorPath: path.resolve(REPO_ROOT, 'release')
})
]
};