From 1a3c561fcdf256f7cf63b83dbd8217efac40e334 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Thu, 28 Mar 2024 16:03:09 -0700 Subject: [PATCH] add 1.42 format test --- .../src/reporters/versions/blobV1.ts | 127 ++++++++++++++++++ tests/assets/blob-1.42.zip | Bin 0 -> 3931 bytes tests/playwright-test/reporter-blob.spec.ts | 49 +++++++ 3 files changed, 176 insertions(+) create mode 100644 packages/playwright/src/reporters/versions/blobV1.ts create mode 100644 tests/assets/blob-1.42.zip diff --git a/packages/playwright/src/reporters/versions/blobV1.ts b/packages/playwright/src/reporters/versions/blobV1.ts new file mode 100644 index 0000000000..5ea9350285 --- /dev/null +++ b/packages/playwright/src/reporters/versions/blobV1.ts @@ -0,0 +1,127 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import type { Metadata } from '../../../types/test'; +import type * as reporterTypes from '../../../types/testReporter'; + +export type JsonLocation = reporterTypes.Location; +export type JsonError = string; +export type JsonStackFrame = { file: string, line: number, column: number }; + +export type JsonStdIOType = 'stdout' | 'stderr'; + +export type JsonConfig = Pick; + +export type JsonPattern = { + s?: string; + r?: { source: string, flags: string }; +}; + +export type JsonProject = { + grep: JsonPattern[]; + grepInvert: JsonPattern[]; + metadata: Metadata; + name: string; + dependencies: string[]; + // This is relative to root dir. + snapshotDir: string; + // This is relative to root dir. + outputDir: string; + repeatEach: number; + retries: number; + suites: JsonSuite[]; + teardown?: string; + // This is relative to root dir. + testDir: string; + testIgnore: JsonPattern[]; + testMatch: JsonPattern[]; + timeout: number; +}; + +export type JsonSuite = { + title: string; + location?: JsonLocation; + suites: JsonSuite[]; + tests: JsonTestCase[]; +}; + +export type JsonTestCase = { + testId: string; + title: string; + location: JsonLocation; + retries: number; + tags?: string[]; + repeatEachIndex: number; +}; + +export type JsonTestEnd = { + testId: string; + expectedStatus: reporterTypes.TestStatus; + timeout: number; + annotations: { type: string, description?: string }[]; +}; + +export type JsonTestResultStart = { + id: string; + retry: number; + workerIndex: number; + parallelIndex: number; + startTime: number; +}; + +export type JsonAttachment = Omit & { base64?: string }; + +export type JsonTestResultEnd = { + id: string; + duration: number; + status: reporterTypes.TestStatus; + errors: reporterTypes.TestError[]; + attachments: JsonAttachment[]; +}; + +export type JsonTestStepStart = { + id: string; + parentStepId?: string; + title: string; + category: string, + startTime: number; + location?: reporterTypes.Location; +}; + +export type JsonTestStepEnd = { + id: string; + duration: number; + error?: reporterTypes.TestError; +}; + +export type JsonFullResult = { + status: reporterTypes.FullResult['status']; + startTime: number; + duration: number; +}; + +export type JsonEvent = { + method: string; + params: any +}; + +export type BlobReportMetadata = { + version: number; + userAgent: string; + name?: string; + shard?: { total: number, current: number }; + pathSeparator?: string; +}; diff --git a/tests/assets/blob-1.42.zip b/tests/assets/blob-1.42.zip new file mode 100644 index 0000000000000000000000000000000000000000..da16671ccc9e0b774f9bcef0a41bd5df867c12c5 GIT binary patch literal 3931 zcmV-h52Wx=O9KQH00;;O0QP-+SO5S3000000000001N;C0CHt;Z*p`lYIARHZ0(&( zb0f!*fbaV&Ci)~PXijClvWk1~TDx{E4hlO~-q?dehpeou8CoR30GifJjQQU;8k`Y` zM}rNZpoVvK8-PF~zs$-OF7w6hY}(wwRr9!z`5)fNv~6yhzueKspXayl-nVbz+Ujd~^A*kSz5UlW_r!nx z{teh``}LdYEX!LB*KYaD_Wk$LJ-MCDo15ls^YrvDpI(ac@3U#SefKz*H3@k6?&@EE zy1kR;rn$a;`|yhl*Ux{tZWql}^X_hz={xoW0#FYE8j9@~e<&*ENRFU9)ZTo#XaOX=qFAk_Ym`2Es?b7|+dpOw&k^7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BUz&;l6N^qm6QZDi0J6_ zxu5Szb5*T58EDCk>o~w-&{?P0wMC6YpIks-=Z&}K^xm+C8VgjTfWNl7co@Pc!?yMs zTYWne7BI!69BomoT`*c_$r6bQ+O>b0jO^z>_58%-*9vd4Ecu(Z}}K0o>7k?TCh>_Mryy7;;(MqVY~TdGe6mg(!eI5`5L7;7vNQ1HRp7z=ttF;Gsw zk5Z7(E31bh_56Pm8%UCr&qT3Ec4#bSW1Mxd zbhV43y+{Z28FwIEMy6M&z%g5}Ts*?^K2i;A8I=nvmD2-e9rC^7b24yju3x~xHYxzE zONtPZ*O0uI=%Kr2CIvb@(VIFK@b4YRlYwJ+ePLWw<`Qfcq@n{l(`{#E(z*b9sZite zppP9`2aNXDb_5)TFiL&;T5dS`t}BibMr-dcs&9v`+XjXrl1c%%7&K9w_)?5cn*F)P-}qV38sANu zEE?~Ef&i#PDoDVbi|CV2v|Os^4Y2rm_H*>0)Vwn1byd9Z$X|b|ILaVCk1=~tDjIWu zDn>QtD7C { + test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/29984' }); + await runInlineTest({ + 'echo-reporter.js': ` + export default class EchoReporter { + lines = []; + onTestBegin(test) { + this.lines.push(test.titlePath().join(' > ')); + } + onEnd() { + console.log(this.lines.join('\\n')); + } + }; + `, + 'merge.config.ts': `module.exports = { + testDir: 'mergeRoot', + reporter: './echo-reporter.js' + };`, + }); + + const blobDir = test.info().outputPath('blob-report'); + await fs.promises.mkdir(blobDir, { recursive: true }); + await fs.promises.copyFile(path.join(__dirname, '../assets/blob-1.42.zip'), path.join(blobDir, 'blob-1.42.zip')); + + const { exitCode, output } = await mergeReports(blobDir, undefined, { additionalArgs: ['--config', 'merge.config.ts'] }); + expect(exitCode).toBe(0); + expect(output).toContain(` > chromium > example.spec.ts > test 0 + > chromium > example.spec.ts > describe 1 > describe 2 > test 3 + > chromium > example.spec.ts > describe 1 > describe 2 > test 4 + > chromium > example.spec.ts > describe 1 > describe 2 > test 2 + > chromium > example.spec.ts > describe 1 > test 1 + > chromium > example.spec.ts > describe 1 > test 5 + > chromium > example.spec.ts > test 6 + > firefox > example.spec.ts > describe 1 > describe 2 > test 2 + > firefox > example.spec.ts > describe 1 > describe 2 > test 3 + > firefox > example.spec.ts > test 0 + > firefox > example.spec.ts > describe 1 > describe 2 > test 4 + > firefox > example.spec.ts > describe 1 > test 1 + > firefox > example.spec.ts > test 6 + > firefox > example.spec.ts > describe 1 > test 5 + > webkit > example.spec.ts > describe 1 > describe 2 > test 4 + > webkit > example.spec.ts > test 0 + > webkit > example.spec.ts > describe 1 > test 1 + > webkit > example.spec.ts > describe 1 > describe 2 > test 2 + > webkit > example.spec.ts > describe 1 > describe 2 > test 3 + > webkit > example.spec.ts > test 6 + > webkit > example.spec.ts > describe 1 > test 5`); +});