Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(trace): only enable on separate tracing bots (#3677)

Dmitry Gozmane5ff283a40d6
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 2f2ce2b8a4..80129485bb 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -184,3 +184,35 @@ jobs:
with:
name: wire-${{ matrix.browser }}-linux-test-results
path: test-results
+
+ tracing_linux:
+ name: "Tracing Linux"
+ strategy:
+ fail-fast: false
+ matrix:
+ browser: [chromium, firefox, webkit]
+ runs-on: ubuntu-18.04
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions/setup-node@v1
+ with:
+ node-version: 10
+ - uses: microsoft/playwright-github-action@v1
+ - run: npm ci
+ - run: npm run build
+ - run: mkdir -p coredumps
+ # Set core dump file name pattern
+ - run: sudo bash -c 'echo "$(pwd -P)/coredumps/core-pid_%p.dump" > /proc/sys/kernel/core_pattern'
+ # XVFB-RUN merges both STDOUT and STDERR, whereas we need only STDERR
+ # Wrap `npm run` in a subshell to redirect STDERR to file.
+ # Enable core dumps in the subshell.
+ - run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && node test-runner/cli test/ --jobs=1 --forbid-only --timeout=30000 --retries=3 --reporter=dot,json"
+ env:
+ BROWSER: ${{ matrix.browser }}
+ TRACING: true
+ PWRUNNER_JSON_REPORT: "test-results/report.json"
+ - uses: actions/upload-artifact@v1
+ if: ${{ always() }}
+ with:
+ name: tracing-${{ matrix.browser }}-linux-test-results
+ path: test-results
diff --git a/test/playwright.fixtures.ts b/test/playwright.fixtures.ts
index 22d0a13803..cf987ac6fc 100644
--- a/test/playwright.fixtures.ts
+++ b/test/playwright.fixtures.ts
@@ -33,6 +33,8 @@ export const options = {
HEADLESS: !!valueFromEnv('HEADLESS', true),
WIRE: !!process.env.PWWIRE,
SLOW_MO: valueFromEnv('SLOW_MO', 0),
+ // Tracing is currently not implemented under wire.
+ TRACING: valueFromEnv('TRACING', false) && !process.env.PWWIRE,
};
declare global {
@@ -183,7 +185,7 @@ registerWorkerFixture('golden', async ({browserName}, test) => {
registerFixture('context', async ({browser, toImpl}, runTest, info) => {
const context = await browser.newContext();
const { test, config } = info;
- if (toImpl) {
+ if (options.TRACING) {
const traceStorageDir = path.join(config.outputDir, 'trace-storage');
const relativePath = path.relative(config.testDir, test.file).replace(/\.spec\.[jt]s/, '');
const sanitizedTitle = test.title.replace(/[^\w\d]+/g, '_');
diff --git a/test/snapshot.spec.ts b/test/snapshot.spec.ts
index a6a70614ce..2e23fcdf2c 100644
--- a/test/snapshot.spec.ts
+++ b/test/snapshot.spec.ts
@@ -16,7 +16,7 @@
import { options } from './playwright.fixtures';
-it.skip(options.WIRE)('should not throw', async ({page, server, context, toImpl}) => {
+it.skip(!options.TRACING)('should not throw', async ({page, server, context, toImpl}) => {
await page.goto(server.PREFIX + '/snapshot/snapshot-with-css.html');
await (context as any).__snapshotter.captureSnapshot(toImpl(page), { timeout: 5000, label: 'snapshot' });
});
diff --git a/utils/showTestTraces.js b/utils/showTestTraces.js
index a018b70e76..5acd9a16ef 100644
--- a/utils/showTestTraces.js
+++ b/utils/showTestTraces.js
@@ -17,7 +17,7 @@
const path = require('path');
const fs = require('fs');
const playwright = require('..');
-const { showTraceViewer } = require('../lib/client/traceViewer');
+const { showTraceViewer } = require('../lib/trace/traceViewer');
const testResultsDir = process.argv[2] || path.join(__dirname, '..', 'test-results');
const files = collectFiles(testResultsDir, '');