* Run prettier on the files that will be refactored under @kbn/test, in a follow-up pr. * Fixup all paths to mocha, under kbn-test, with needed exports/imports. * Fixed borked path (bad refactor). * Fixup one more borked path. * Fixup tsconfig for xml.ts * Drop setup_node_env as it's already in KIBANA/scripts/mocha.js. Also, fixup cwd for globby as we are exec-ing from a different directory. Co-authored-by: Tre <wayne.seymour@elastic.co>
This commit is contained in:
parent
74dfc79f1d
commit
2a0f465fe6
|
@ -23,12 +23,11 @@ import Mocha from 'mocha';
|
|||
import { ToolingLogTextWriter } from '@kbn/dev-utils';
|
||||
import moment from 'moment';
|
||||
|
||||
import { setupJUnitReportGeneration } from '../../../../../../../src/dev';
|
||||
import { recordLog, snapshotLogsForRunnable, setupJUnitReportGeneration } from '../../../../mocha';
|
||||
import * as colors from './colors';
|
||||
import * as symbols from './symbols';
|
||||
import { ms } from './ms';
|
||||
import { writeEpilogue } from './write_epilogue';
|
||||
import { recordLog, snapshotLogsForRunnable } from '../../../../../../../src/dev/mocha/log_cache';
|
||||
|
||||
export function MochaReporterProvider({ getService }) {
|
||||
const log = getService('log');
|
||||
|
|
|
@ -46,6 +46,13 @@ export { readConfigFile } from './functional_test_runner/lib/config/read_config_
|
|||
|
||||
export { runFtrCli } from './functional_test_runner/cli';
|
||||
|
||||
export {
|
||||
createAutoJUnitReporter,
|
||||
runMochaCli,
|
||||
setupJUnitReportGeneration,
|
||||
escapeCdata,
|
||||
} from './mocha';
|
||||
|
||||
export { runFailedTestsReporterCli } from './failed_tests_reporter';
|
||||
|
||||
export { CI_PARALLEL_PROCESS_PREFIX } from './ci_parallel_process_prefix';
|
||||
|
|
|
@ -23,3 +23,7 @@ export { createAutoJUnitReporter } from './auto_junit_reporter';
|
|||
export { setupJUnitReportGeneration } from './junit_report_generation';
|
||||
// @ts-ignore not typed yet
|
||||
export { runMochaCli } from './run_mocha_cli';
|
||||
// @ts-ignore not typed yet
|
||||
export { recordLog, snapshotLogsForRunnable } from './log_cache';
|
||||
// @ts-ignore not typed yet
|
||||
export { escapeCdata } from './xml';
|
|
@ -25,14 +25,14 @@ import xmlBuilder from 'xmlbuilder';
|
|||
import { getUniqueJunitReportPath } from '@kbn/test';
|
||||
|
||||
import { getSnapshotOfRunnableLogs } from './log_cache';
|
||||
import { escapeCdata } from '../xml';
|
||||
import { escapeCdata } from '../';
|
||||
|
||||
const dateNow = Date.now.bind(Date);
|
||||
|
||||
export function setupJUnitReportGeneration(runner, options = {}) {
|
||||
const {
|
||||
reportName = 'Unnamed Mocha Tests',
|
||||
rootDirectory = dirname(require.resolve('../../../package.json')),
|
||||
rootDirectory = dirname(require.resolve('../../../../package.json')),
|
||||
getTestMetadata = () => ({}),
|
||||
} = options;
|
||||
|
|
@ -40,9 +40,6 @@ export function runMochaCli() {
|
|||
// prevent globals injected from canvas plugins from triggering leak check
|
||||
process.argv.push('--globals', '__core-js_shared__,core,_, ');
|
||||
|
||||
// ensure that mocha requires the setup_node_env script
|
||||
process.argv.push('--require', require.resolve('../../setup_node_env'));
|
||||
|
||||
// set default test timeout
|
||||
if (opts.timeout == null && !opts['no-timeouts']) {
|
||||
if (runInBand) {
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
// when the reporter is loaded by mocha in child process it might be before setup_node_env
|
||||
require('../../setup_node_env');
|
||||
require('../../../../src/setup_node_env');
|
||||
|
||||
module.exports = require('./auto_junit_reporter').createAutoJUnitReporter({
|
||||
reportName: 'Server Mocha Tests',
|
|
@ -18,4 +18,4 @@
|
|||
*/
|
||||
|
||||
require('../src/setup_node_env');
|
||||
require('../src/dev/mocha').runMochaCli();
|
||||
require('@kbn/test').runMochaCli();
|
||||
|
|
|
@ -17,6 +17,6 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export { createAutoJUnitReporter, setupJUnitReportGeneration } from './mocha';
|
||||
export { createAutoJUnitReporter, setupJUnitReportGeneration } from '@kbn/test';
|
||||
|
||||
export { generateNoticeFromSource } from './notice';
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// @ts-ignore
|
||||
import regenerate from 'regenerate';
|
||||
import stripAnsi from 'strip-ansi';
|
||||
|
||||
// create a regular expression using regenerate() that selects any character that is explicitly allowed by https://www.w3.org/TR/xml/#NT-Char
|
||||
const validXmlCharsRE = new RegExp(
|
||||
`(?:${regenerate()
|
||||
.add(0x9, 0xa, 0xd)
|
||||
.addRange(0x20, 0xd7ff)
|
||||
.addRange(0xe000, 0xfffd)
|
||||
.addRange(0x10000, 0x10ffff)
|
||||
.toString()})*`,
|
||||
'g'
|
||||
);
|
||||
|
||||
export function escapeCdata(input: string) {
|
||||
const match = stripAnsi(input).match(validXmlCharsRE) || [];
|
||||
return match.join('');
|
||||
}
|
Loading…
Reference in a new issue