mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-14 13:45:36 +03:00
chore: remove worker isolation options (#20176)
This commit is contained in:
parent
d9d4070520
commit
3fd0530076
@ -483,7 +483,6 @@ export const baseFullConfig: FullConfigInternal = {
|
||||
_storeDir: '',
|
||||
_maxConcurrentTestGroups: 0,
|
||||
_ignoreSnapshots: false,
|
||||
_workerIsolation: 'isolate-pools',
|
||||
_globalScripts: null,
|
||||
_globalProject: { } as FullProjectInternal,
|
||||
};
|
||||
|
@ -439,7 +439,7 @@ export class Dispatcher {
|
||||
}
|
||||
|
||||
_createWorker(testGroup: TestGroup, parallelIndex: number, loaderData: SerializedLoaderData) {
|
||||
const worker = new WorkerHost(testGroup, parallelIndex, this._configLoader.fullConfig()._workerIsolation, loaderData);
|
||||
const worker = new WorkerHost(testGroup, parallelIndex, loaderData);
|
||||
const handleOutput = (params: TestOutputPayload) => {
|
||||
const chunk = chunkFromParams(params);
|
||||
if (worker.didFail()) {
|
||||
|
@ -29,11 +29,6 @@ export type TtyParams = {
|
||||
colorDepth: number;
|
||||
};
|
||||
|
||||
export type WorkerIsolation =
|
||||
'isolate-projects' | // create new worker for new project type
|
||||
'isolate-pools'; // create new worker for new worker fixture pool digest
|
||||
|
||||
|
||||
export type ProcessInitParams = {
|
||||
stdoutParams: TtyParams;
|
||||
stderrParams: TtyParams;
|
||||
@ -41,7 +36,6 @@ export type ProcessInitParams = {
|
||||
};
|
||||
|
||||
export type WorkerInitParams = {
|
||||
workerIsolation: WorkerIsolation;
|
||||
workerIndex: number;
|
||||
parallelIndex: number;
|
||||
repeatEachIndex: number;
|
||||
|
@ -18,7 +18,6 @@ import * as path from 'path';
|
||||
import { calculateSha1 } from 'playwright-core/lib/utils';
|
||||
import { FixturePool, isFixtureOption } from './fixtures';
|
||||
import { setCurrentlyLoadingFileSuite } from './globals';
|
||||
import type { WorkerIsolation } from './ipc';
|
||||
import { Suite, type TestCase } from './test';
|
||||
import type { TestTypeImpl } from './testType';
|
||||
import { requireOrImport } from './transform';
|
||||
@ -86,7 +85,7 @@ export class TestLoader {
|
||||
if (!this._projectSuiteBuilders.has(project))
|
||||
this._projectSuiteBuilders.set(project, new ProjectSuiteBuilder(project));
|
||||
const builder = this._projectSuiteBuilders.get(project)!;
|
||||
return builder.cloneFileSuite(suite, 'isolate-pools', repeatEachIndex, filter);
|
||||
return builder.cloneFileSuite(suite, repeatEachIndex, filter);
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,14 +132,14 @@ class ProjectSuiteBuilder {
|
||||
return this._testPools.get(test)!;
|
||||
}
|
||||
|
||||
private _cloneEntries(from: Suite, to: Suite, workerIsolation: WorkerIsolation, repeatEachIndex: number, filter: (test: TestCase) => boolean): boolean {
|
||||
private _cloneEntries(from: Suite, to: Suite, repeatEachIndex: number, filter: (test: TestCase) => boolean): boolean {
|
||||
for (const entry of from._entries) {
|
||||
if (entry instanceof Suite) {
|
||||
const suite = entry._clone();
|
||||
suite._fileId = to._fileId;
|
||||
to._addSuite(suite);
|
||||
// Ignore empty titles, similar to Suite.titlePath().
|
||||
if (!this._cloneEntries(entry, suite, workerIsolation, repeatEachIndex, filter)) {
|
||||
if (!this._cloneEntries(entry, suite, repeatEachIndex, filter)) {
|
||||
to._entries.pop();
|
||||
to.suites.pop();
|
||||
}
|
||||
@ -166,10 +165,7 @@ class ProjectSuiteBuilder {
|
||||
to.tests.pop();
|
||||
} else {
|
||||
const pool = this._buildPool(entry);
|
||||
if (this._project._fullConfig._workerIsolation === 'isolate-pools')
|
||||
test._workerHash = `run${this._project._id}-${pool.digest}-repeat${repeatEachIndex}`;
|
||||
else
|
||||
test._workerHash = `run${this._project._id}-repeat${repeatEachIndex}`;
|
||||
test._workerHash = `run${this._project._id}-${pool.digest}-repeat${repeatEachIndex}`;
|
||||
test._pool = pool;
|
||||
}
|
||||
}
|
||||
@ -179,11 +175,11 @@ class ProjectSuiteBuilder {
|
||||
return true;
|
||||
}
|
||||
|
||||
cloneFileSuite(suite: Suite, workerIsolation: WorkerIsolation, repeatEachIndex: number, filter: (test: TestCase) => boolean): Suite | undefined {
|
||||
cloneFileSuite(suite: Suite, repeatEachIndex: number, filter: (test: TestCase) => boolean): Suite | undefined {
|
||||
const result = suite._clone();
|
||||
const relativeFile = path.relative(this._project.testDir, suite.location!.file).split(path.sep).join('/');
|
||||
result._fileId = calculateSha1(relativeFile).slice(0, 20);
|
||||
return this._cloneEntries(suite, result, workerIsolation, repeatEachIndex, filter) ? result : undefined;
|
||||
return this._cloneEntries(suite, result, repeatEachIndex, filter) ? result : undefined;
|
||||
}
|
||||
|
||||
private _applyConfigUseOptions(testType: TestTypeImpl, configUse: Fixtures): FixturesWithLocation[] {
|
||||
|
@ -229,7 +229,7 @@ export async function requireOrImport(file: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export function installTransform(): () => void {
|
||||
function installTransform(): () => void {
|
||||
let reverted = false;
|
||||
|
||||
const originalResolveFilename = (Module as any)._resolveFilename;
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
import type { Fixtures, TestInfoError, Project } from '../types/test';
|
||||
import type { Location, Reporter } from '../types/testReporter';
|
||||
import type { WorkerIsolation } from './ipc';
|
||||
import type { FullConfig as FullConfigPublic, FullProject as FullProjectPublic } from './types';
|
||||
export * from '../types/test';
|
||||
export type { Location } from '../types/testReporter';
|
||||
@ -48,7 +47,6 @@ export interface FullConfigInternal extends FullConfigPublic {
|
||||
_storeDir: string;
|
||||
_maxConcurrentTestGroups: number;
|
||||
_ignoreSnapshots: boolean;
|
||||
_workerIsolation: WorkerIsolation;
|
||||
/**
|
||||
* If populated, this should also be the first/only entry in _webServers. Legacy singleton `webServer` as well as those provided via an array in the user-facing playwright.config.{ts,js} will be in `_webServers`. The legacy field (`webServer`) field additionally stores the backwards-compatible singleton `webServer` since it had been showing up in globalSetup to the user.
|
||||
*/
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import type { TestGroup } from './dispatcher';
|
||||
import type { RunPayload, SerializedLoaderData, WorkerInitParams, WorkerIsolation } from './ipc';
|
||||
import type { RunPayload, SerializedLoaderData, WorkerInitParams } from './ipc';
|
||||
import { ProcessHost } from './processHost';
|
||||
|
||||
let lastWorkerIndex = 0;
|
||||
@ -27,7 +27,7 @@ export class WorkerHost extends ProcessHost<WorkerInitParams> {
|
||||
currentTestId: string | null = null;
|
||||
private _params: WorkerInitParams;
|
||||
|
||||
constructor(testGroup: TestGroup, parallelIndex: number, workerIsolation: WorkerIsolation, loader: SerializedLoaderData) {
|
||||
constructor(testGroup: TestGroup, parallelIndex: number, loader: SerializedLoaderData) {
|
||||
const workerIndex = lastWorkerIndex++;
|
||||
super(require.resolve('./workerRunner.js'), `worker-${workerIndex}`);
|
||||
this.workerIndex = workerIndex;
|
||||
@ -35,7 +35,6 @@ export class WorkerHost extends ProcessHost<WorkerInitParams> {
|
||||
this._hash = testGroup.workerHash;
|
||||
|
||||
this._params = {
|
||||
workerIsolation,
|
||||
workerIndex: this.workerIndex,
|
||||
parallelIndex,
|
||||
repeatEachIndex: testGroup.repeatEachIndex,
|
||||
|
@ -262,14 +262,8 @@ export class WorkerRunner extends ProcessRunner {
|
||||
}
|
||||
};
|
||||
|
||||
if (!this._isStopped) {
|
||||
// Update the fixture pool - it may differ between tests.
|
||||
// - In case of isolate-pools worker isolation, only test-scoped fixtures may differ.
|
||||
// - In case of isolate-projects, worker fixtures can differ too, tear down worker fixture scope if they differ.
|
||||
if (this._params.workerIsolation === 'isolate-projects' && this._fixtureRunner.pool && this._fixtureRunner.pool.digest !== test._pool!.digest)
|
||||
await this._teardownScopes();
|
||||
if (!this._isStopped)
|
||||
this._fixtureRunner.setPool(test._pool!);
|
||||
}
|
||||
|
||||
const suites = getSuites(test);
|
||||
const reversedSuites = suites.slice().reverse();
|
||||
|
Loading…
Reference in New Issue
Block a user