remove watchAllTests
This commit is contained in:
parent
fce88122c6
commit
000e0574e5
|
|
@ -24,9 +24,9 @@ import { stopProfiling, startProfiling, gracefullyProcessExitDoNotHang } from 'p
|
||||||
import { serializeError } from './util';
|
import { serializeError } from './util';
|
||||||
import { showHTMLReport } from './reporters/html';
|
import { showHTMLReport } from './reporters/html';
|
||||||
import { createMergedReport } from './reporters/merge';
|
import { createMergedReport } from './reporters/merge';
|
||||||
import { loadConfigFromFileRestartIfNeeded, loadEmptyConfigForMergeReports } from './common/configLoader';
|
import { loadConfigFromFileRestartIfNeeded, loadEmptyConfigForMergeReports, resolveConfigLocation } from './common/configLoader';
|
||||||
import type { ConfigCLIOverrides } from './common/ipc';
|
import type { ConfigCLIOverrides } from './common/ipc';
|
||||||
import type { FullResult, TestError } from '../types/testReporter';
|
import type { TestError } from '../types/testReporter';
|
||||||
import type { TraceMode } from '../types/test';
|
import type { TraceMode } from '../types/test';
|
||||||
import { builtInReporters, defaultReporter, defaultTimeout } from './common/config';
|
import { builtInReporters, defaultReporter, defaultTimeout } from './common/config';
|
||||||
import { program } from 'playwright-core/lib/cli/program';
|
import { program } from 'playwright-core/lib/cli/program';
|
||||||
|
|
@ -35,6 +35,7 @@ import type { ReporterDescription } from '../types/test';
|
||||||
import { prepareErrorStack } from './reporters/base';
|
import { prepareErrorStack } from './reporters/base';
|
||||||
import * as testServer from './runner/testServer';
|
import * as testServer from './runner/testServer';
|
||||||
import { clearCacheAndLogToConsole } from './runner/testServer';
|
import { clearCacheAndLogToConsole } from './runner/testServer';
|
||||||
|
import { runWatchModeLoop } from './runner/watchMode';
|
||||||
|
|
||||||
function addTestCommand(program: Command) {
|
function addTestCommand(program: Command) {
|
||||||
const command = program.command('test [test-filter...]');
|
const command = program.command('test [test-filter...]');
|
||||||
|
|
@ -157,9 +158,6 @@ async function runTests(args: string[], opts: { [key: string]: any }) {
|
||||||
await startProfiling();
|
await startProfiling();
|
||||||
const cliOverrides = overridesFromOptions(opts);
|
const cliOverrides = overridesFromOptions(opts);
|
||||||
|
|
||||||
if (process.env.PWTEST_WATCH && opts.onlyChanged)
|
|
||||||
throw new Error(`--only-changed is not supported in watch mode. If you'd like that to change, file an issue and let us know about your usecase for it.`);
|
|
||||||
|
|
||||||
if (opts.ui || opts.uiHost || opts.uiPort) {
|
if (opts.ui || opts.uiHost || opts.uiPort) {
|
||||||
if (opts.onlyChanged)
|
if (opts.onlyChanged)
|
||||||
throw new Error(`--only-changed is not supported in UI mode. If you'd like that to change, see https://github.com/microsoft/playwright/issues/15075 for more details.`);
|
throw new Error(`--only-changed is not supported in UI mode. If you'd like that to change, see https://github.com/microsoft/playwright/issues/15075 for more details.`);
|
||||||
|
|
@ -186,6 +184,24 @@ async function runTests(args: string[], opts: { [key: string]: any }) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (process.env.PWTEST_WATCH) {
|
||||||
|
if (opts.onlyChanged)
|
||||||
|
throw new Error(`--only-changed is not supported in watch mode. If you'd like that to change, file an issue and let us know about your usecase for it.`);
|
||||||
|
|
||||||
|
const status = await runWatchModeLoop(
|
||||||
|
resolveConfigLocation(opts.config),
|
||||||
|
{
|
||||||
|
projects: opts.project,
|
||||||
|
files: args,
|
||||||
|
grep: opts.grep
|
||||||
|
}
|
||||||
|
);
|
||||||
|
await stopProfiling('runner');
|
||||||
|
const exitCode = status === 'interrupted' ? 130 : (status === 'passed' ? 0 : 1);
|
||||||
|
gracefullyProcessExitDoNotHang(exitCode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const config = await loadConfigFromFileRestartIfNeeded(opts.config, cliOverrides, opts.deps === false);
|
const config = await loadConfigFromFileRestartIfNeeded(opts.config, cliOverrides, opts.deps === false);
|
||||||
if (!config)
|
if (!config)
|
||||||
return;
|
return;
|
||||||
|
|
@ -205,11 +221,7 @@ async function runTests(args: string[], opts: { [key: string]: any }) {
|
||||||
config.cliFailOnFlakyTests = !!opts.failOnFlakyTests;
|
config.cliFailOnFlakyTests = !!opts.failOnFlakyTests;
|
||||||
|
|
||||||
const runner = new Runner(config);
|
const runner = new Runner(config);
|
||||||
let status: FullResult['status'];
|
const status = await runner.runAllTests();
|
||||||
if (process.env.PWTEST_WATCH)
|
|
||||||
status = await runner.watchAllTests();
|
|
||||||
else
|
|
||||||
status = await runner.runAllTests();
|
|
||||||
await stopProfiling('runner');
|
await stopProfiling('runner');
|
||||||
const exitCode = status === 'interrupted' ? 130 : (status === 'passed' ? 0 : 1);
|
const exitCode = status === 'interrupted' ? 130 : (status === 'passed' ? 0 : 1);
|
||||||
gracefullyProcessExitDoNotHang(exitCode);
|
gracefullyProcessExitDoNotHang(exitCode);
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ import { collectFilesForProject, filterProjects } from './projectUtils';
|
||||||
import { createReporters } from './reporters';
|
import { createReporters } from './reporters';
|
||||||
import { TestRun, createTaskRunner, createTaskRunnerForList } from './tasks';
|
import { TestRun, createTaskRunner, createTaskRunnerForList } from './tasks';
|
||||||
import type { FullConfigInternal } from '../common/config';
|
import type { FullConfigInternal } from '../common/config';
|
||||||
import { runWatchModeLoop } from './watchMode';
|
|
||||||
import type { Suite } from '../common/test';
|
import type { Suite } from '../common/test';
|
||||||
import { wrapReporterAsV2 } from '../reporters/reporterV2';
|
import { wrapReporterAsV2 } from '../reporters/reporterV2';
|
||||||
import { affectedTestFiles } from '../transform/compilationCache';
|
import { affectedTestFiles } from '../transform/compilationCache';
|
||||||
|
|
@ -131,15 +130,6 @@ export class Runner {
|
||||||
return { status, suite: testRun.rootSuite, errors };
|
return { status, suite: testRun.rootSuite, errors };
|
||||||
}
|
}
|
||||||
|
|
||||||
async watchAllTests(): Promise<FullResult['status']> {
|
|
||||||
const config = this._config;
|
|
||||||
webServerPluginsForConfig(config).forEach(p => config.plugins.push({ factory: p }));
|
|
||||||
return await runWatchModeLoop(
|
|
||||||
{ configDir: config.configDir, resolvedConfigFile: config.config.configFile },
|
|
||||||
{ projects: config.cliProjectFilter, files: config.cliArgs, grep: config.cliGrep }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async findRelatedTestFiles(mode: 'in-process' | 'out-of-process', files: string[]): Promise<FindRelatedTestFilesReport> {
|
async findRelatedTestFiles(mode: 'in-process' | 'out-of-process', files: string[]): Promise<FindRelatedTestFilesReport> {
|
||||||
const result = await this.loadAllTests(mode);
|
const result = await this.loadAllTests(mode);
|
||||||
if (result.status !== 'passed' || !result.suite)
|
if (result.status !== 'passed' || !result.suite)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue