зеркало из https://github.com/microsoft/onnxjs.git
tool: add chromium edge test launcher (#204)
This commit is contained in:
Родитель
89d22d8f02
Коммит
82216b3998
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT license.
|
||||
|
||||
const bundleMode = require('minimist')(process.argv)['bundle-mode'] || 'dev'; // 'dev'|'perf'|undefined;
|
||||
const karmaPlugins = require('minimist')(process.argv)['karma-plugins'] || undefined;
|
||||
const mainFile = bundleMode === 'perf' ? 'test/onnx.perf.js' : 'test/onnx.dev.js';
|
||||
|
||||
// it's a known issue that Safari does not work with "localhost" in BrowserStack:
|
||||
|
@ -53,6 +54,7 @@ module.exports = function(config) {
|
|||
'/onnx-wasm.wasm': '/base/dist/onnx-wasm.wasm',
|
||||
'/onnx-worker.js': '/base/test/onnx-worker.js',
|
||||
},
|
||||
plugins: karmaPlugins,
|
||||
client: { captureConsole: true, mocha: { expose: ['body'], timeout: 60000 } },
|
||||
preprocessors: { mainFile: ['sourcemap'] },
|
||||
reporters: ['mocha', 'BrowserStack'],
|
||||
|
|
|
@ -30,6 +30,12 @@
|
|||
"js-tokens": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"@chiragrupani/karma-chromium-edge-launcher": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@chiragrupani/karma-chromium-edge-launcher/-/karma-chromium-edge-launcher-2.0.0.tgz",
|
||||
"integrity": "sha512-ZSuKymhFJSXRweLOb76jN5oBGR24dL+tplQRYYyEhiXLBnRsbbUChyrlCXVF/V4BaK+o+erfhPhvgX7BzoWk4g==",
|
||||
"dev": true
|
||||
},
|
||||
"@electron/get": {
|
||||
"version": "1.12.2",
|
||||
"resolved": "https://registry.npmjs.org/@electron/get/-/get-1.12.2.tgz",
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
"platform": "^1.3.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@chiragrupani/karma-chromium-edge-launcher": "^2.0.0",
|
||||
"@types/chai": "^4.2.11",
|
||||
"@types/fs-extra": "^9.0.1",
|
||||
"@types/karma": "^5.0.0",
|
||||
|
|
|
@ -6,6 +6,7 @@ import * as fs from 'fs';
|
|||
import * as globby from 'globby';
|
||||
import {default as minimatch} from 'minimatch';
|
||||
import npmlog from 'npmlog';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import stripJsonComments from 'strip-json-comments';
|
||||
import {inspect} from 'util';
|
||||
|
@ -457,6 +458,31 @@ function run(config: Test.Config) {
|
|||
karmaArgs.push('--no-sandbox');
|
||||
}
|
||||
karmaArgs.push(`--bundle-mode=${args.bundleMode}`);
|
||||
if (browser === 'Edge') {
|
||||
// There are currently 2 Edge browser launchers:
|
||||
// - karma-edge-launcher: used to launch the old Edge browser
|
||||
// - karma-chromium-edge-launcher: used to launch the new chromium-kernel Edge browser
|
||||
//
|
||||
|
||||
// Those 2 plugins cannot be loaded at the same time, so we need to determine which launchers to use.
|
||||
// - If we use 'karma-edge-launcher', no plugins config need to be set.
|
||||
// - If we use 'karma-chromium-edge-launcher', we need to:
|
||||
// - add plugin "@chiragrupani/karma-chromium-edge-launcher" explicitly, because it does not match the
|
||||
// default plugins config "^karma-.*"
|
||||
// - remove "karma-edge-launcher".
|
||||
|
||||
// check if we have the latest Edge installed:
|
||||
if (os.platform() === 'darwin' ||
|
||||
(os.platform() === 'win32' &&
|
||||
// tslint:disable-next-line:no-require-imports no-submodule-imports
|
||||
require('@chiragrupani/karma-chromium-edge-launcher/dist/Utilities').default.GetEdgeExe('Edge') !== '')) {
|
||||
// use "@chiragrupani/karma-chromium-edge-launcher"
|
||||
karmaArgs.push(
|
||||
'--karma-plugins=@chiragrupani/karma-chromium-edge-launcher',
|
||||
'--karma-plugins=(?!karma-edge-launcher$)karma-*');
|
||||
} else {
|
||||
// use "karma-edge-launcher"
|
||||
|
||||
// == Special treatment to Microsoft Edge ==
|
||||
//
|
||||
// == Edge's Auto Recovery Feature ==
|
||||
|
@ -474,13 +500,13 @@ function run(config: Test.Config) {
|
|||
// for Microsoft Edge, we should clean up the previous active page before each run
|
||||
// delete the files stores in the specific folder to clean up the recovery page list.
|
||||
// see also: https://www.laptopmag.com/articles/edge-browser-stop-tab-restore
|
||||
if (browser === 'Edge') {
|
||||
const deleteEdgeActiveRecoveryCommand =
|
||||
// tslint:disable-next-line:max-line-length
|
||||
`del /F /Q %LOCALAPPDATA%\\Packages\\Microsoft.MicrosoftEdge_8wekyb3d8bbwe\\AC\\MicrosoftEdge\\User\\Default\\Recovery\\Active\\*`;
|
||||
npmlog.info('TestRunnerCli.Run', `CMD: ${deleteEdgeActiveRecoveryCommand}`);
|
||||
spawnSync(deleteEdgeActiveRecoveryCommand, {shell: true, stdio: 'inherit'});
|
||||
}
|
||||
}
|
||||
npmlog.info('TestRunnerCli.Run', `CMD: ${karmaCommand} ${karmaArgs.join(' ')}`);
|
||||
const karma = spawnSync(karmaCommand, karmaArgs, {shell: true, stdio: 'inherit'});
|
||||
if (karma.status !== 0) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче