Stephen McGruer | 16f7943 | 2020-10-07 13:11:05 | [diff] [blame] | 1 | # Using upstream wptrunner in Chromium (experimental) |
| 2 | |
| 3 | This page documents the *experimental* support for using the upstream |
| 4 | [`wptrunner`](https://github.com/web-platform-tests/wpt/tree/master/tools/wptrunner/) |
| 5 | tooling for running WPT tests in Chromium (vs the [current |
| 6 | approach](web_platform_tests.md#Running-tests) that uses `run_web_tests.py`). |
| 7 | |
| 8 | It is written as a user guide. For technical details on the project, see the |
| 9 | [design doc](https://docs.google.com/document/d/1Pq5fxR1t2JzOVPynqeRpRS4bM4QO_Z1um0Q_RiR5ETA/edit). |
| 10 | |
| 11 | [TOC] |
| 12 | |
| 13 | ## Differences versus `run_web_tests.py` |
| 14 | |
| 15 | The main differences between `run_web_tests.py` and `wptrunner` are that: |
| 16 | |
| 17 | 1. `wptrunner` runs the full `chrome` binary, rather than the stripped-down |
| 18 | `content_shell`, and |
| 19 | 1. `wptrunner` communicates with the binary via WebDriver (`chromedriver`), |
| 20 | instead of talking directly to the browser binary. |
| 21 | |
| 22 | These differences mean that any feature that works on upstream WPT today (e.g. |
| 23 | print-reftests) should work in `wptrunner`, but conversely features available to |
| 24 | `run_web_tests.py` (e.g. the `internals` API) are not yet available to |
| 25 | `wptrunner`. |
| 26 | |
| 27 | ## Running tests locally |
| 28 | |
| 29 | *** note |
| 30 | **NOTE**: Running locally is an area of active development, so the following |
| 31 | instructions may be out of date. |
| 32 | *** |
| 33 | |
| 34 | The runner script is |
| 35 | [`testing/scripts/run_wpt_tests.py`](https://source.chromium.org/chromium/chromium/src/+/master:testing/scripts/run_wpt_tests.py). |
| 36 | Before running the script, you must have built the necessary ninja targets: |
| 37 | |
| 38 | ``` |
| 39 | autoninja -C out/Release wpt_tests_isolate |
| 40 | ``` |
| 41 | |
| 42 | To run the script, you must enter the `testing/scripts/` directory before |
| 43 | executing it: |
| 44 | |
| 45 | ``` |
| 46 | cd testing/scripts |
Stephen McGruer | 5383e3c0 | 2020-11-05 13:16:38 | [diff] [blame] | 47 | ./run_wpt_tests.py [test list] |
Stephen McGruer | 16f7943 | 2020-10-07 13:11:05 | [diff] [blame] | 48 | ``` |
| 49 | |
Stephen McGruer | 5383e3c0 | 2020-11-05 13:16:38 | [diff] [blame] | 50 | The list of tests should be given relative to `external/wpt/`, e.g. |
| 51 | `webauthn/createcredential-timeout.https.html`. Directories are also accepted. |
| 52 | Omitting the test list will run all WPT tests. |
Stephen McGruer | 16f7943 | 2020-10-07 13:11:05 | [diff] [blame] | 53 | |
Stephen McGruer | 5383e3c0 | 2020-11-05 13:16:38 | [diff] [blame] | 54 | Results from the run are placed in your build folder, in a folder called |
| 55 | `layout-test-results` (e.g. `../../out/Release/layout-test-results/`). Logs from |
| 56 | the browser should be shown by the runner as it executes each test. |
Stephen McGruer | 16f7943 | 2020-10-07 13:11:05 | [diff] [blame] | 57 | |
| 58 | Useful flags: |
| 59 | |
| 60 | * `-t/--target`: select which `src/out/` sub-directory to use, e.g. `-t Debug`. |
| 61 | Defaults to `Release`. |
| 62 | * `--help`: show the help text |
| 63 | |
| 64 | ## The MVP bots |
| 65 | |
| 66 | As of Q4 2020, an MVP of wptrunner in Chromium is being run with two customer |
| 67 | teams: Web Payments and Web Identity. For these teams, two **Linux-only** bots |
| 68 | have been brought up: |
| 69 | |
| 70 | * [linux-wpt-identity-fyi-rel](https://ci.chromium.org/p/chromium/builders/ci/linux-wpt-identity-fyi-rel), |
| 71 | which runs tests under `external/wpt/webauthn/`. |
Luke Zielinski | 5ce5d37 | 2020-12-01 19:19:47 | [diff] [blame^] | 72 | * [linux-wpt-input-fyi-rel](https://ci.chromium.org/p/chromium/builders/ci/linux-wpt-input-fyi-rel), |
| 73 | which runs tests under `external/wpt/{input-events, pointerevents, uievents}`, |
| 74 | as well as `external/wpt/infrastructure/testdriver/actions/` |
Stephen McGruer | 16f7943 | 2020-10-07 13:11:05 | [diff] [blame] | 75 | |
| 76 | These bots run on the waterfall, but can also be run on CLs by clicking the |
| 77 | `Choose Tryjobs` button in Gerrit followed by searching for the bot name in the |
| 78 | modal dialog that appears. One can also include the tag `Cq-Include-Trybots: |
Luke Zielinski | 5ce5d37 | 2020-12-01 19:19:47 | [diff] [blame^] | 79 | luci.chromium.try:linux-wpt-identity-fyi-rel` (or input) in the description |
Stephen McGruer | 16f7943 | 2020-10-07 13:11:05 | [diff] [blame] | 80 | for the CL, which will make the bot mandatory for that CL. |
| 81 | |
| 82 | Results for the bots use the existing layout test results viewer |
| 83 | ([example](https://test-results.appspot.com/data/layout_results/linux-wpt-identity-fyi-rel/201/wpt_tests_suite/layout-test-results/results.html)). |
| 84 | |
| 85 | ## Expectations and baseline files |
| 86 | |
| 87 | [Similar to `run_web_tests.py`](web_test_expectations.md), `wptrunner` offers |
| 88 | the ability to add an expected status for a test or provide a baseline file that |
| 89 | codifies what the output result should be. |
| 90 | |
| 91 | By default `wptrunner` will inherit expected statuses from `TestExpecations`. |
| 92 | This can currently be overridden by adding an entry to the |
| 93 | [`WPTOverrideExpectations`](https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/web_tests/WPTOverrideExpectations) |
| 94 | file when `wptrunner` has a different result than `run_web_tests.py`. |
| 95 | `WPTOverrideExpectations` is however [deprecated](https://crbug.com/1035911), |
| 96 | and the preferred method for specifying expected results for `wptrunner` is to |
| 97 | use baseline files (which will also override a TestExpectation entry for the |
| 98 | test). |
| 99 | |
| 100 | Baseline files for `wptrunner` use a different filename and format than |
| 101 | the `-expected.txt` files used by `run_web_tests.py`. The ini-like baseline format is |
| 102 | [documented here](https://web-platform-tests.org/tools/wptrunner/docs/expectation.html), |
| 103 | and baseline files should be placed alongside the test with an `.ini` suffix: |
| 104 | |
| 105 | ``` |
| 106 | external/wpt/folder/my-test.html |
| 107 | external/wpt/folder/my-test-expected.txt <-- run_web_tests.py baseline |
| 108 | external/wpt/folder/my-test.html.ini <-- wptrunner baseline |
| 109 | ``` |
| 110 | |
| 111 | We currently do not support the full ini-like format that upstream WPT does; |
| 112 | most notably we have chosen not to support dynamic conditionals (such as |
| 113 | platform checks). Most `.ini` baseline files in Chromium should have the form: |
| 114 | |
| 115 | ``` |
| 116 | [my-test.html] |
| 117 | expected: OK |
| 118 | |
| 119 | [First subtest name] |
| 120 | expected: FAIL |
| 121 | message: The failure message, e.g. assert_false didn't work |
| 122 | |
| 123 | [Second subtest name] |
| 124 | expected: PASS |
| 125 | ``` |
| 126 | |
| 127 | *** note |
| 128 | **TODO**: Explain how .any.js and variants work in this world. |
| 129 | *** |
| 130 | |
| 131 | ## Known issues |
| 132 | |
Stephen McGruer | 16f7943 | 2020-10-07 13:11:05 | [diff] [blame] | 133 | * There is no debugging support in `run_wpt_tests.py` today. In the future, we |
| 134 | intend to allow pausing the browser after each test, and (long-term) intend to |
| 135 | support hooking up gdb to test runs. |
| 136 | * There is not yet support for non-Linux platforms. We would love for you to try |
| 137 | it on other operating systems and file bugs against us if it doesn't work! |
| 138 | |
| 139 | Please [file bugs and feature requests](https://crbug.com/new) against |
| 140 | `Blink>Infra>Ecosystem`, tagging the title with `[wptrunner]`. |