diff --git a/packages/playwright/src/reporters/merge.ts b/packages/playwright/src/reporters/merge.ts index e91c7305ec..5eedcac136 100644 --- a/packages/playwright/src/reporters/merge.ts +++ b/packages/playwright/src/reporters/merge.ts @@ -194,25 +194,22 @@ async function mergeEvents(dir: string, shardReportFiles: string[], stringPool: printStatus(`merging events`); const reports: ReportData[] = []; - const testIdsUsedInOtherBlobs = new Set(); + const globalTestIdSet = new Set(); for (let i = 0; i < blobs.length; ++i) { // Generate unique salt for each blob. const { parsedEvents, metadata, localPath } = blobs[i]; const eventPatchers = new JsonEventPatchers(); - const testIdsUsedInThisBlob = new Set(); eventPatchers.patchers.push(new IdsPatcher( stringPool, metadata.name, String(i), - testIdsUsedInThisBlob, - testIdsUsedInOtherBlobs, + globalTestIdSet, )); // Only patch path separators if we are merging reports with explicit config. if (rootDirOverride) eventPatchers.patchers.push(new PathSeparatorPatcher(metadata.pathSeparator)); eventPatchers.patchEvents(parsedEvents); - testIdsUsedInThisBlob.forEach(id => testIdsUsedInOtherBlobs.add(id)); for (const event of parsedEvents) { if (event.method === 'onConfigure') @@ -368,22 +365,19 @@ class IdsPatcher { private _botName: string | undefined; private _salt: string; private _testIdsMap: Map; - private _testIdsUsedInThisBlob: Set; - private _testIdsUsedInOtherBlobs: Set; + private _globalTestIdSet: Set; constructor( stringPool: StringInternPool, botName: string | undefined, salt: string, - testIdsUsedInThisBlob: Set, - testIdsUsedInOtherBlobs: Set, + globalTestIdSet: Set, ) { this._stringPool = stringPool; this._botName = botName; this._salt = salt; this._testIdsMap = new Map(); - this._testIdsUsedInThisBlob = testIdsUsedInThisBlob; - this._testIdsUsedInOtherBlobs = testIdsUsedInOtherBlobs; + this._globalTestIdSet = globalTestIdSet; } patchEvent(event: JsonEvent) { @@ -431,14 +425,14 @@ class IdsPatcher { if (this._testIdsMap.has(t1)) // already mapped return this._testIdsMap.get(t1)!; - if (this._testIdsUsedInOtherBlobs.has(t1)) { + if (this._globalTestIdSet.has(t1)) { // test id is used in another blob, so we need to salt it. const t2 = this._stringPool.internString(testId + this._salt); - this._testIdsUsedInThisBlob.add(t2); + this._globalTestIdSet.add(t2); this._testIdsMap.set(t1, t2); return t2; } - this._testIdsUsedInThisBlob.add(t1); + this._globalTestIdSet.add(t1); this._testIdsMap.set(t1, t1); return t1; }