From a0b1f6b401abae2fbc5a8987061644adfaa7b482 Mon Sep 17 00:00:00 2001 From: Jan Scheffler Date: Tue, 14 Sep 2021 17:21:06 +0200 Subject: [PATCH] feat: add unit test support for bisect (#7553) --- CONTRIBUTING.md | 6 +++- utils/bisect.js | 93 ++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 81 insertions(+), 18 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a40178380d2..344b75fb24b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -292,12 +292,16 @@ The following steps are needed to update the Chromium version. ### Bisecting upstream changes -Sometimes, performing a Chromium roll causes tests to fail. To figure out the cause, you need to bisect Chromium revisions to figure out the earliest possible revision that changed the behavior. The script in `utils/bisect.js` can be helpful here. Given a Node.js script that calls `process.exit(1)` for bad revisions, run this from the Puppeteer repository’s root directory: +Sometimes, performing a Chromium roll causes tests to fail. To figure out the cause, you need to bisect Chromium revisions to figure out the earliest possible revision that changed the behavior. The script in `utils/bisect.js` can be helpful here. Given a pattern for one or more unit tests, it will automatically bisect the current range: ```sh node utils/bisect.js --good 686378 --bad 706915 script.js + +node utils/bisect.js --unit-test Response.fromCache ``` +By default, it will use the Chromium revision in `src/revisions.ts` from the `main` branch and from the working tree to determine the range to bisect. + ## Releasing to npm Releasing to npm consists of the following phases: diff --git a/utils/bisect.js b/utils/bisect.js index d81fdec8f59..60b7ba07c61 100755 --- a/utils/bisect.js +++ b/utils/bisect.js @@ -21,7 +21,7 @@ const pptr = require('..'); const browserFetcher = pptr.createBrowserFetcher(); const path = require('path'); const fs = require('fs'); -const { fork } = require('child_process'); +const { fork, spawn, execSync } = require('child_process'); const COLOR_RESET = '\x1b[0m'; const COLOR_RED = '\x1b[31m'; @@ -35,12 +35,16 @@ Usage: node bisect.js --good --bad