chore: apply rebaselines in a task (#33549)

This commit is contained in:
Pavel Feldman 2024-11-11 21:15:05 -08:00 committed by GitHub
parent a501232bf0
commit 1b65f26f02
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 5 deletions

View File

@ -19,12 +19,11 @@ import type { FullResult, TestError } from '../../types/testReporter';
import { webServerPluginsForConfig } from '../plugins/webServerPlugin';
import { collectFilesForProject, filterProjects } from './projectUtils';
import { createErrorCollectingReporter, createReporters } from './reporters';
import { TestRun, createClearCacheTask, createGlobalSetupTasks, createLoadTask, createPluginSetupTasks, createReportBeginTask, createRunTestsTasks, createStartDevServerTask, runTasks } from './tasks';
import { TestRun, createApplyRebaselinesTask, createClearCacheTask, createGlobalSetupTasks, createLoadTask, createPluginSetupTasks, createReportBeginTask, createRunTestsTasks, createStartDevServerTask, runTasks } from './tasks';
import type { FullConfigInternal } from '../common/config';
import { affectedTestFiles } from '../transform/compilationCache';
import { InternalReporter } from '../reporters/internalReporter';
import { LastRunReporter } from './lastRun';
import { applySuggestedRebaselines } from './rebase';
type ProjectConfigWithFiles = {
name: string;
@ -83,14 +82,13 @@ export class Runner {
createLoadTask('in-process', { failOnLoadErrors: true, filterOnly: false }),
createReportBeginTask(),
] : [
createApplyRebaselinesTask(),
...createGlobalSetupTasks(config),
createLoadTask('in-process', { filterOnly: true, failOnLoadErrors: true }),
...createRunTestsTasks(config),
];
const status = await runTasks(new TestRun(config, reporter), tasks, config.config.globalTimeout);
await applySuggestedRebaselines(config, reporter);
// Calling process.exit() might truncate large stdout/stderr output.
// See https://github.com/nodejs/node/issues/6456.
// See https://github.com/nodejs/node/issues/12921

View File

@ -34,6 +34,7 @@ import { detectChangedTestFiles } from './vcs';
import type { InternalReporter } from '../reporters/internalReporter';
import { cacheDir } from '../transform/compilationCache';
import type { FullResult } from '../../types/testReporter';
import { applySuggestedRebaselines } from './rebase';
const readDirAsync = promisify(fs.readdir);
@ -280,6 +281,15 @@ export function createLoadTask(mode: 'out-of-process' | 'in-process', options: {
};
}
export function createApplyRebaselinesTask(): Task<TestRun> {
return {
title: 'apply rebaselines',
teardown: async ({ config, reporter }) => {
await applySuggestedRebaselines(config, reporter);
},
};
}
function createPhasesTask(): Task<TestRun> {
return {
title: 'create phases',

View File

@ -23,7 +23,7 @@ import type * as reporterTypes from '../../types/testReporter';
import { affectedTestFiles, collectAffectedTestFiles, dependenciesForTestFile } from '../transform/compilationCache';
import type { ConfigLocation, FullConfigInternal } from '../common/config';
import { createErrorCollectingReporter, createReporterForTestServer, createReporters } from './reporters';
import { TestRun, runTasks, createLoadTask, createRunTestsTasks, createReportBeginTask, createListFilesTask, runTasksDeferCleanup, createClearCacheTask, createGlobalSetupTasks, createStartDevServerTask } from './tasks';
import { TestRun, runTasks, createLoadTask, createRunTestsTasks, createReportBeginTask, createListFilesTask, runTasksDeferCleanup, createClearCacheTask, createGlobalSetupTasks, createStartDevServerTask, createApplyRebaselinesTask } from './tasks';
import { open } from 'playwright-core/lib/utilsBundle';
import ListReporter from '../reporters/list';
import { SigIntWatcher } from './sigIntWatcher';
@ -336,6 +336,7 @@ export class TestServerDispatcher implements TestServerInterface {
const reporter = new InternalReporter([...configReporters, wireReporter]);
const stop = new ManualPromise();
const tasks = [
createApplyRebaselinesTask(),
createLoadTask('out-of-process', { filterOnly: true, failOnLoadErrors: false, doNotRunDepsOutsideProjectFilter: true }),
...createRunTestsTasks(config),
];