chore: remove clearCompilationCache, do not push cache it into loader… (#29548)

This commit is contained in:
Pavel Feldman 2024-02-19 10:21:05 -08:00 committed by GitHub
parent 31bd58f8f3
commit a99652b0d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 10 additions and 17 deletions

View File

@ -93,7 +93,8 @@ export class ConfigLoader {
}
static async deserialize(data: SerializedConfig): Promise<FullConfigInternal> {
addToCompilationCache(data.compilationCache);
if (data.compilationCache)
addToCompilationCache(data.compilationCache);
const loader = new ConfigLoader(data.configCLIOverrides);
const config = data.configFile ? await loader.loadConfigFile(data.configFile) : await loader.loadEmptyConfig(data.configDir);

View File

@ -134,12 +134,12 @@ export type TeardownErrorsPayload = {
export type EnvProducedPayload = [string, string | null][];
export function serializeConfig(config: FullConfigInternal): SerializedConfig {
export function serializeConfig(config: FullConfigInternal, passCompilationCache: boolean): SerializedConfig {
const result: SerializedConfig = {
configFile: config.config.configFile,
configDir: config.configDir,
configCLIOverrides: config.configCLIOverrides,
compilationCache: serializeCompilationCache(),
compilationCache: passCompilationCache ? serializeCompilationCache() : undefined,
};
return result;
}

View File

@ -97,7 +97,7 @@ export class Dispatcher {
// 2. Start the worker if it is down.
let startError;
if (!worker) {
worker = this._createWorker(job, index, serializeConfig(this._config));
worker = this._createWorker(job, index, serializeConfig(this._config, true));
this._workerSlots[index].worker = worker;
worker.on('exit', () => this._workerSlots[index].worker = undefined);
startError = await worker.start();

View File

@ -59,7 +59,7 @@ export class OutOfProcessLoaderHost {
}
async start(errors: TestError[]) {
const startError = await this._processHost.startRunner(serializeConfig(this._config));
const startError = await this._processHost.startRunner(serializeConfig(this._config, false));
if (startError) {
errors.push({
message: `Test loader process failed to start with code "${startError.code}" and signal "${startError.signal}"`,

View File

@ -110,7 +110,7 @@ export class Runner {
return status;
}
async loadAllTests(): Promise<{ status: FullResult['status'], suite?: Suite, errors: TestError[] }> {
async loadAllTests(mode: 'in-process' | 'out-of-process' = 'in-process'): Promise<{ status: FullResult['status'], suite?: Suite, errors: TestError[] }> {
const config = this._config;
const errors: TestError[] = [];
const reporter = new InternalReporter(new Multiplexer([wrapReporterAsV2({
@ -118,7 +118,7 @@ export class Runner {
errors.push(error);
}
})]));
const taskRunner = createTaskRunnerForList(config, reporter, 'in-process', { failOnLoadErrors: true });
const taskRunner = createTaskRunnerForList(config, reporter, mode, { failOnLoadErrors: true });
const testRun = new TestRun(config, reporter);
reporter.onConfigure(config.config);

View File

@ -17,7 +17,7 @@
import { openTraceViewerApp, openTraceInBrowser, registry } from 'playwright-core/lib/server';
import { isUnderTest, ManualPromise } from 'playwright-core/lib/utils';
import type { FullResult } from '../../types/testReporter';
import { clearCompilationCache, collectAffectedTestFiles, dependenciesForTestFile } from '../transform/compilationCache';
import { collectAffectedTestFiles, dependenciesForTestFile } from '../transform/compilationCache';
import type { FullConfigInternal } from '../common/config';
import { InternalReporter } from '../reporters/internalReporter';
import { TeleReporterEmitter } from '../reporters/teleEmitter';
@ -172,7 +172,6 @@ class UIMode {
this._config.testIdMatcher = undefined;
const taskRunner = createTaskRunnerForList(this._config, reporter, 'out-of-process', { failOnLoadErrors: false });
const testRun = new TestRun(this._config, reporter);
clearCompilationCache();
reporter.onConfigure(this._config.config);
const status = await taskRunner.run(testRun, 0);
await reporter.onEnd({ status });
@ -200,7 +199,6 @@ class UIMode {
const reporter = new InternalReporter(new Multiplexer(reporters));
const taskRunner = createTaskRunnerForWatch(this._config, reporter);
const testRun = new TestRun(this._config, reporter);
clearCompilationCache();
reporter.onConfigure(this._config.config);
const stop = new ManualPromise();
const run = taskRunner.run(testRun, 0, stop).then(async status => {

View File

@ -22,7 +22,7 @@ import { createFileMatcher, createFileMatcherFromArguments } from '../util';
import type { Matcher } from '../util';
import { TestRun, createTaskRunnerForWatch, createTaskRunnerForWatchSetup } from './tasks';
import { buildProjectsClosure, filterProjects } from './projectUtils';
import { clearCompilationCache, collectAffectedTestFiles } from '../transform/compilationCache';
import { collectAffectedTestFiles } from '../transform/compilationCache';
import type { FullResult } from '../../types/testReporter';
import { chokidar } from '../utilsBundle';
import type { FSWatcher as CFSWatcher } from 'chokidar';
@ -283,7 +283,6 @@ async function runTests(config: FullConfigInternal, failedTestIdCollector: Set<s
const reporter = new InternalReporter(new ListReporter());
const taskRunner = createTaskRunnerForWatch(config, reporter, options?.additionalFileMatcher);
const testRun = new TestRun(config, reporter);
clearCompilationCache();
reporter.onConfigure(config.config);
const taskStatus = await taskRunner.run(testRun, 0);
let status: FullResult['status'] = 'passed';

View File

@ -158,11 +158,6 @@ export function serializeCompilationCache(): SerializedCompilationCache {
};
}
export function clearCompilationCache() {
sourceMaps.clear();
memoryCache.clear();
}
export function addToCompilationCache(payload: any) {
for (const entry of payload.sourceMaps)
sourceMaps.set(entry[0], entry[1]);