Skip to content

Commit f98bd09

Browse files
committed
test(reporter): fail gzip perfetto writes with a fifo
Repeated x compresses too well, so /dev/full never errors. Write incompressible data to a fifo and close the reader so the dest stream errors. Signed-off-by: Sebastien Tardif <[email protected]>
1 parent a12b55e commit f98bd09

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎tests/playwright-test/reporter-perfetto.spec.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { execFileSync } from 'child_process';
18+
import * as crypto from 'crypto';
1719
import * as fs from 'fs';
1820
import * as path from 'path';
1921
import * as zlib from 'zlib';
@@ -216,20 +218,23 @@ test('should report step params', async ({ runInlineTest }, testInfo) => {
216218
});
217219

218220
test('should fail when gzip perfetto output stream errors', async ({ runInlineTest }, testInfo) => {
219-
test.skip(!fs.existsSync('/dev/full'), 'needs /dev/full');
220221
const gz = testInfo.outputPath('trace.json.gz');
221-
await fs.promises.symlink('/dev/full', gz);
222+
execFileSync('mkfifo', [gz]);
223+
const reader = fs.createReadStream(gz);
224+
reader.on('error', () => {});
225+
reader.once('data', () => reader.destroy());
222226
const result = await runInlineTest({
223227
'playwright.config.ts': `
224228
module.exports = { reporter: [['perfetto', { outputFile: ${JSON.stringify(gz)} }]] };
225229
`,
226230
'a.test.ts': `
227231
import { test } from '@playwright/test';
228232
test('one', async () => {
229-
test.info().annotations.push({ type: 'blob', description: ${JSON.stringify('x'.repeat(64 * 1024))} });
233+
test.info().annotations.push({ type: 'blob', description: ${JSON.stringify(crypto.randomBytes(256 * 1024).toString('base64'))} });
230234
});
231235
`,
232236
});
237+
reader.destroy();
233238
expect(result.exitCode).not.toBe(0);
234239
});
235240

0 commit comments

Comments
 (0)