use separate LastRunReporter instances

This commit is contained in:
Mathias Leppich 2024-09-11 20:45:07 +02:00
parent b78b88fbac
commit f62651cfd0
4 changed files with 10 additions and 9 deletions

View file

@ -24,7 +24,6 @@ import { getPackageJsonPath, mergeObjects } from '../util';
import type { Matcher } from '../util';
import type { ConfigCLIOverrides } from './ipc';
import type { FullConfig, FullProject } from '../../types/testReporter';
import { LastRunReporter } from '../runner/lastRun';
export type ConfigLocation = {
resolvedConfigFile?: string;
@ -59,7 +58,6 @@ export class FullConfigInternal {
defineConfigWasUsed = false;
shardingMode: ShardingMode;
lastRunFile: string | undefined;
readonly lastRunReporter: LastRunReporter;
constructor(location: ConfigLocation, userConfig: Config, configCLIOverrides: ConfigCLIOverrides) {
if (configCLIOverrides.projects && userConfig.projects)
@ -135,8 +133,6 @@ export class FullConfigInternal {
resolveProjectDependencies(this.projects);
this._assignUniqueProjectIds(this.projects);
this.config.projects = this.projects.map(p => p.project);
this.lastRunReporter = new LastRunReporter(this);
}
private _assignUniqueProjectIds(projects: FullProjectInternal[]) {

View file

@ -28,6 +28,7 @@ import { currentBlobReportVersion, type BlobReportMetadata } from './blob';
import { relativeFilePath } from '../util';
import type { TestError } from '../../types/testReporter';
import type * as blobV1 from './versions/blobV1';
import { LastRunReporter } from '../runner/lastRun';
type StatusCallback = (message: string) => void;
@ -39,7 +40,8 @@ type ReportData = {
export async function createMergedReport(config: FullConfigInternal, dir: string, reporterDescriptions: ReporterDescription[], rootDirOverride: string | undefined) {
const reporters = await createReporters(config, 'merge', false, reporterDescriptions);
const multiplexer = new Multiplexer([...reporters, config.lastRunReporter]);
const lastRun = new LastRunReporter(config);
const multiplexer = new Multiplexer([...reporters, lastRun]);
const stringPool = new StringInternPool();
let printStatus: StatusCallback = () => {};

View file

@ -24,6 +24,7 @@ import { TestRun, createTaskRunner, createTaskRunnerForClearCache, createTaskRun
import type { FullConfigInternal } from '../common/config';
import { affectedTestFiles } from '../transform/compilationCache';
import { InternalReporter } from '../reporters/internalReporter';
import { LastRunReporter } from './lastRun';
type ProjectConfigWithFiles = {
name: string;
@ -74,10 +75,11 @@ export class Runner {
webServerPluginsForConfig(config).forEach(p => config.plugins.push({ factory: p }));
const reporters = await createReporters(config, listOnly ? 'list' : 'test', false);
const lastRun = new LastRunReporter(config);
if (config.cliLastFailed)
await config.lastRunReporter.filterLastFailed();
await lastRun.filterLastFailed();
const reporter = new InternalReporter([...reporters, config.lastRunReporter]);
const reporter = new InternalReporter([...reporters, lastRun]);
const taskRunner = listOnly ? createTaskRunnerForList(
config,
reporter,

View file

@ -16,7 +16,7 @@
import type { FullConfigInternal } from '../common/config';
import type { Suite, TestCase } from '../common/test';
import type { LastRunInfo } from './lastRun';
import { LastRunReporter, type LastRunInfo } from './lastRun';
export type TestGroup = {
workerHash: string;
@ -144,7 +144,8 @@ export async function filterForShard(config: FullConfigInternal, testGroups: Tes
if (mode === 'round-robin')
return filterForShardRoundRobin(shard, testGroups);
if (mode === 'duration-round-robin') {
const lastRunInfo = await config.lastRunReporter.lastRunInfo();
const lastRun = new LastRunReporter(config);
const lastRunInfo = await lastRun.lastRunInfo();
return filterForShardRoundRobin(shard, testGroups, lastRunInfo);
}
return filterForShardPartition(shard, testGroups);