blob: 7c82f3cadf19d67cd4fd4ac2a8b0287c9537ea53 [file] [log] [blame] [view]
Kent Tamura59ffb022018-11-27 05:30:561# Web Test Expectations and Baselines
pwnalld8a250722016-11-09 18:24:032
3
Kent Tamura59ffb022018-11-27 05:30:564The primary function of the web tests is as a regression test suite; this
pwnalld8a250722016-11-09 18:24:035means that, while we care about whether a page is being rendered correctly, we
6care more about whether the page is being rendered the way we expect it to. In
7other words, we look more for changes in behavior than we do for correctness.
8
9[TOC]
10
Kent Tamura59ffb022018-11-27 05:30:5611All web tests have "expected results", or "baselines", which may be one of
pwnalld8a250722016-11-09 18:24:0312several forms. The test may produce one or more of:
13
14* A text file containing JavaScript log messages.
15* A text rendering of the Render Tree.
16* A screen capture of the rendered page as a PNG file.
17* WAV files of the audio output, for WebAudio tests.
18
Kent Tamura59ffb022018-11-27 05:30:5619For any of these types of tests, baselines are checked into the web_tests
Robert Ma06f7acc2017-11-14 17:55:4720directory. The filename of a baseline is the same as that of the corresponding
21test, but the extension is replaced with `-expected.{txt,png,wav}` (depending on
22the type of test output). Baselines usually live alongside tests, with the
23exception when baselines vary by platforms; read
Kent Tamura59ffb022018-11-27 05:30:5624[Web Test Baseline Fallback](web_test_baseline_fallback.md) for more
Robert Ma06f7acc2017-11-14 17:55:4725details.
26
27Lastly, we also support the concept of "reference tests", which check that two
28pages are rendered identically (pixel-by-pixel). As long as the two tests'
29output match, the tests pass. For more on reference tests, see
pwnalld8a250722016-11-09 18:24:0330[Writing ref tests](https://trac.webkit.org/wiki/Writing%20Reftests).
31
32## Failing tests
33
34When the output doesn't match, there are two potential reasons for it:
35
36* The port is performing "correctly", but the output simply won't match the
37 generic version. The usual reason for this is for things like form controls,
38 which are rendered differently on each platform.
39* The port is performing "incorrectly" (i.e., the test is failing).
40
41In both cases, the convention is to check in a new baseline (aka rebaseline),
42even though that file may be codifying errors. This helps us maintain test
43coverage for all the other things the test is testing while we resolve the bug.
44
45*** promo
46If a test can be rebaselined, it should always be rebaselined instead of adding
47lines to TestExpectations.
48***
49
50Bugs at [crbug.com](https://crbug.com) should track fixing incorrect behavior,
51not lines in
Kent Tamura59ffb022018-11-27 05:30:5652[TestExpectations](../../third_party/blink/web_tests/TestExpectations). If a
pwnalld8a250722016-11-09 18:24:0353test is never supposed to pass (e.g. it's testing Windows-specific behavior, so
54can't ever pass on Linux/Mac), move it to the
Kent Tamura59ffb022018-11-27 05:30:5655[NeverFixTests](../../third_party/blink/web_tests/NeverFixTests) file. That
pwnalld8a250722016-11-09 18:24:0356gets it out of the way of the rest of the project.
57
58There are some cases where you can't rebaseline and, unfortunately, we don't
59have a better solution than either:
60
611. Reverting the patch that caused the failure, or
622. Adding a line to TestExpectations and fixing the bug later.
63
64In this case, **reverting the patch is strongly preferred**.
65
66These are the cases where you can't rebaseline:
67
68* The test is a reference test.
69* The test gives different output in release and debug; in this case, generate a
70 baseline with the release build, and mark the debug build as expected to fail.
71* The test is flaky, crashes or times out.
72* The test is for a feature that hasn't yet shipped on some platforms yet, but
73 will shortly.
74
75## Handling flaky tests
76
77The
78[flakiness dashboard](https://test-results.appspot.com/dashboards/flakiness_dashboard.html)
79is a tool for understanding a test’s behavior over time.
80Originally designed for managing flaky tests, the dashboard shows a timeline
81view of the test’s behavior over time. The tool may be overwhelming at first,
82but
83[the documentation](https://dev.chromium.org/developers/testing/flakiness-dashboard)
84should help. Once you decide that a test is truly flaky, you can suppress it
85using the TestExpectations file, as described below.
86
87We do not generally expect Chromium sheriffs to spend time trying to address
88flakiness, though.
89
90## How to rebaseline
91
92Since baselines themselves are often platform-specific, updating baselines in
93general requires fetching new test results after running the test on multiple
94platforms.
95
96### Rebaselining using try jobs
97
98The recommended way to rebaseline for a currently-in-progress CL is to use
Quinten Yearsleya58f83c2017-05-30 16:00:5799results from try jobs, by using the command-tool
Kent Tamurab53757e2018-04-20 17:54:48100`third_party/blink/tools/blink_tool.py rebaseline-cl`:
pwnalld8a250722016-11-09 18:24:03101
Quinten Yearsleya58f83c2017-05-30 16:00:571021. First, upload a CL.
Kent Tamurab53757e2018-04-20 17:54:481032. Trigger try jobs by running `blink_tool.py rebaseline-cl`. This should
Quinten Yearsleya58f83c2017-05-30 16:00:57104 trigger jobs on
Preethi Mohan6ad00ee2020-11-17 03:09:42105 [tryserver.blink](https://ci.chromium.org/p/chromium/g/tryserver.blink/builders).
106 In addition, this will also trigger the CQ try builders that run blink web tests.
107 linux-rel, mac-rel and win10_chromium_x64_rel_ng.
Preethi Mohandd8288842021-03-03 02:03:48108 * Optionally one can choose to trigger only blink try bots alone.
Preethi Mohan6ad00ee2020-11-17 03:09:42109 Run the tool with the option -
110 `blink_tool.py rebaseline-cl --use-blink-try-bots-only`
Weizhong Xia832f3c02021-08-30 04:10:29111 * If you would like to rebaseline for flag specific builders, use the flag-specific option.
112 Rebaseline for highdpi, disable-layout-ng and composite-after-paint are
113 supported for now. For example, to rebaseline for highdpi, use
Preethi Mohandd8288842021-03-03 02:03:48114 `blink_tool.py rebaseline-cl --flag-specific=highdpi`. This will trigger
115 only the highdpi try builder. Since this is an experimental builder at this time,
116 this will not be triggered with the default or '--use-blink-try-bots-only' options.
Weizhong Xia832f3c02021-08-30 04:10:29117 * If you need to trigger all the builders including supported flag-specific builders, run the
118 tool with desired options multiple times. There is no need to wait for the builders
119 triggered with default option to finish before triggering the flag specific
120 builders and vice versa.
pwnalld8a250722016-11-09 18:24:031213. Wait for all try jobs to finish.
Kent Tamurab53757e2018-04-20 17:54:481224. Run `blink_tool.py rebaseline-cl` again to fetch new baselines.
Quinten Yearsleya58f83c2017-05-30 16:00:57123 By default, this will download new baselines for any failing tests
Preethi Mohan6ad00ee2020-11-17 03:09:42124 in the blink try jobs and CQ try bots.
Preethi Mohandd8288842021-03-03 02:03:48125 * Again, there is an option to use only blink try jobs results for rebaselining.
Kent Tamurab53757e2018-04-20 17:54:48126 (Run `blink_tool.py rebaseline-cl --help` for more specific options.)
Weizhong Xia832f3c02021-08-30 04:10:29127 * To rebaseline for flag-specific builders (using highdpi as an example again), runs -
Preethi Mohandd8288842021-03-03 02:03:48128 `blink_tool.py rebaseline-cl --flag-specific=highdpi` which will download baselines
Weizhong Xia832f3c02021-08-30 04:10:29129 for any failures in the highdpi run only. We suggest running flag-specific rebaseline
130 after non-flag-specific rebaseline as baseline optimization is not
131 implemented for flag-specific rebaseline yet.
pwnalld8a250722016-11-09 18:24:031325. Commit the new baselines and upload a new patch.
133
134This way, the new baselines can be reviewed along with the changes, which helps
135the reviewer verify that the new baselines are correct. It also means that there
Kent Tamura59ffb022018-11-27 05:30:56136is no period of time when the web test results are ignored.
pwnalld8a250722016-11-09 18:24:03137
Quinten Yearsleya58f83c2017-05-30 16:00:57138#### Options
139
Kent Tamurab53757e2018-04-20 17:54:48140The tests which `blink_tool.py rebaseline-cl` tries to download new baselines for
pwnalld8a250722016-11-09 18:24:03141depends on its arguments.
142
143* By default, it tries to download all baselines for tests that failed in the
144 try jobs.
145* If you pass `--only-changed-tests`, then only tests modified in the CL will be
146 considered.
147* You can also explicitly pass a list of test names, and then just those tests
148 will be rebaselined.
Quinten Yearsleya58f83c2017-05-30 16:00:57149* If some of the try jobs failed to run, and you wish to continue rebaselining
150 assuming that there are no platform-specific results for those platforms,
151 you can add the flag `--fill-missing`.
Xianzhu Wangc5e2eaf12020-01-16 22:13:09152* By default, it finds the try jobs by looking at the latest patchset. If you
153 have finished try jobs that are associated with an earlier patchset and you
154 want to use them instead of scheduling new try jobs, you can add the flag
155 `--patchset=n` to specify the patchset. This is very useful when the CL has
156 'trivial' patchsets that are created e.g. by editing the CL descrpition.
157
Xianzhu Wang61d49d52021-07-31 16:44:53158### Rebaseline script in results.html
159
160Web test results.html linked from bot job result page provides an alternative
161way to rebaseline tests for a particular platform.
162
163* In the bot job result page, find the web test results.html link and click it.
164* Choose "Rebaseline script" from the dropdown list after "Test shown ... in format".
165* Click "Copy report" (or manually copy part of the script for the tests you want
166 to rebaseline).
167* In local console, change directory into `third_party/blink/web_tests/platform/<platform>`.
168* Paste.
169* Add files into git and commit.
170
Xianzhu Wangdca49022021-08-27 20:50:11171The generated command includes `blink_tool.py optimize-baselines <tests>` which
172removes redundant baselines. However, the optimization doesn't work for
173flag-specific baselines for now, so the rebaseline script may create redundant
174baselines for flag-specific results. We prefer local manual rebaselining (see
175below) for flag-specific rebaselines when possible.
Xianzhu Wang61d49d52021-07-31 16:44:53176
Xianzhu Wangc5e2eaf12020-01-16 22:13:09177### Local manual rebaselining
178
Xianzhu Wang61d49d52021-07-31 16:44:53179```bash
180third_party/blink/tools/run_web_tests.py --reset-results foo/bar/test.html
181```
pwnalld8a250722016-11-09 18:24:03182
Xianzhu Wang61d49d52021-07-31 16:44:53183If there are current expectation files for `web_tests/foo/bar/test.html`,
184the above command will overwrite the current baselines at their original
185locations with the actual results. The current baseline means the `-expected.*`
186file used to compare the actual result when the test is run locally, i.e. the
187first file found in the [baseline search path](https://cs.chromium.org/search/?q=port/base.py+baseline_search_path).
188
189If there are no current baselines, the above command will create new baselines
190in the platform-independent directory, e.g.
191`web_tests/foo/bar/test-expected.{txt,png}`.
192
193When you rebaseline a test, make sure your commit description explains why the
194test is being re-baselined.
195
196### Rebaselining flag-specific expectations
197
198See [Testing Runtime Flags](./web_tests.md#Testing-Runtime-Flags) for details
199about flag-specific expectations.
200
201Though we prefer the [Rebaseline Tool](#How-to-rebaseline) to local rebaselining,
202the Rebaseline Tool doesn't support rebaselining flag-specific expectations except
203highdpi.
204
205```bash
206third_party/blink/tools/run_web_tests.py --flag-specific=config --reset-results foo/bar/test.html
207```
208
209New baselines will be created in the flag-specific baselines directory, e.g.
210`web_tests/flag-specific/config/foo/bar/test-expected.{txt,png}`
211
212Then you can commit the new baselines and upload the patch for review.
213
214Sometimes it's difficult for reviewers to review the patch containing only new
215files. You can follow the steps below for easier review.
216
2171. Copy existing baselines to the flag-specific baselines directory for the
218 tests to be rebaselined:
219 ```bash
220 third_party/blink/tools/run_web_tests.py --flag-specific=config --copy-baselines foo/bar/test.html
221 ```
222 Then add the newly created baseline files, commit and upload the patch.
223 Note that the above command won't copy baselines for passing tests.
224
2252. Rebaseline the test locally:
226 ```bash
227 third_party/blink/tools/run_web_tests.py --flag-specific=config --reset-results foo/bar/test.html
228 ```
229 Commit the changes and upload the patch.
230
2313. Request review of the CL and tell the reviewer to compare the patch sets that
232 were uploaded in step 1 and step 2 to see the differences of the rebaselines.
233
pwnalld8a250722016-11-09 18:24:03234## Kinds of expectations files
235
Kent Tamura59ffb022018-11-27 05:30:56236* [TestExpectations](../../third_party/blink/web_tests/TestExpectations): The
Quinten Yearsleyd13299d2017-07-25 17:22:17237 main test failure suppression file. In theory, this should be used for
238 temporarily marking tests as flaky.
Kent Tamura59ffb022018-11-27 05:30:56239* [ASANExpectations](../../third_party/blink/web_tests/ASANExpectations):
pwnalld8a250722016-11-09 18:24:03240 Tests that fail under ASAN.
Kent Tamura59ffb022018-11-27 05:30:56241* [LeakExpectations](../../third_party/blink/web_tests/LeakExpectations):
pwnalld8a250722016-11-09 18:24:03242 Tests that have memory leaks under the leak checker.
Kent Tamura59ffb022018-11-27 05:30:56243* [MSANExpectations](../../third_party/blink/web_tests/MSANExpectations):
pwnalld8a250722016-11-09 18:24:03244 Tests that fail under MSAN.
Kent Tamura59ffb022018-11-27 05:30:56245* [NeverFixTests](../../third_party/blink/web_tests/NeverFixTests): Tests
pwnalld8a250722016-11-09 18:24:03246 that we never intend to fix (e.g. a test for Windows-specific behavior will
247 never be fixed on Linux/Mac). Tests that will never pass on any platform
248 should just be deleted, though.
Kent Tamura59ffb022018-11-27 05:30:56249* [SlowTests](../../third_party/blink/web_tests/SlowTests): Tests that take
pwnalld8a250722016-11-09 18:24:03250 longer than the usual timeout to run. Slow tests are given 5x the usual
251 timeout.
Kent Tamura59ffb022018-11-27 05:30:56252* [SmokeTests](../../third_party/blink/web_tests/SmokeTests): A small subset
Stephen McGruer7878d062021-01-15 20:23:20253 of tests that we run on the Fuchsia bots.
Kent Tamura59ffb022018-11-27 05:30:56254* [StaleTestExpectations](../../third_party/blink/web_tests/StaleTestExpectations):
pwnalld8a250722016-11-09 18:24:03255 Platform-specific lines that have been in TestExpectations for many months.
256 They're moved here to get them out of the way of people doing rebaselines
257 since they're clearly not getting fixed anytime soon.
Kent Tamura59ffb022018-11-27 05:30:56258* [W3CImportExpectations](../../third_party/blink/web_tests/W3CImportExpectations):
pwnalld8a250722016-11-09 18:24:03259 A record of which W3C tests should be imported or skipped.
pwnalld8a250722016-11-09 18:24:03260
261### Flag-specific expectations files
262
263It is possible to handle tests that only fail when run with a particular flag
264being passed to `content_shell`. See
Kent Tamura59ffb022018-11-27 05:30:56265[web_tests/FlagExpectations/README.txt](../../third_party/blink/web_tests/FlagExpectations/README.txt)
pwnalld8a250722016-11-09 18:24:03266for more.
267
268## Updating the expectations files
269
270### Ordering
271
272The file is not ordered. If you put new changes somewhere in the middle of the
273file, this will reduce the chance of merge conflicts when landing your patch.
274
275### Syntax
276
Xianzhu Wang61d49d52021-07-31 16:44:53277*** promo
278Please see [The Chromium Test List Format](http://bit.ly/chromium-test-list-format)
279for a more complete and up-to-date description of the syntax.
280***
281
pwnalld8a250722016-11-09 18:24:03282The syntax of the file is roughly one expectation per line. An expectation can
283apply to either a directory of tests, or a specific tests. Lines prefixed with
284`# ` are treated as comments, and blank lines are allowed as well.
285
286The syntax of a line is roughly:
287
288```
Xianzhu Wang61d49d52021-07-31 16:44:53289[ bugs ] [ "[" modifiers "]" ] test_name_or_directory [ "[" expectations "]" ]
pwnalld8a250722016-11-09 18:24:03290```
291
292* Tokens are separated by whitespace.
293* **The brackets delimiting the modifiers and expectations from the bugs and the
Xianzhu Wang61d49d52021-07-31 16:44:53294 test_name_or_directory are not optional**; however the modifiers component is optional. In
pwnalld8a250722016-11-09 18:24:03295 other words, if you want to specify modifiers or expectations, you must
296 enclose them in brackets.
Xianzhu Wang61d49d52021-07-31 16:44:53297* If test_name_or_directory is a directory, it should be ended with '/*', and all
298 tests under the directory will have the expectations, unless overridden by
299 more specific expectation lines.
pwnalld8a250722016-11-09 18:24:03300* Lines are expected to have one or more bug identifiers, and the linter will
301 complain about lines missing them. Bug identifiers are of the form
302 `crbug.com/12345`, `code.google.com/p/v8/issues/detail?id=12345` or
303 `Bug(username)`.
304* If no modifiers are specified, the test applies to all of the configurations
305 applicable to that file.
Johanne1b8bd502021-11-14 21:06:47306* If specified, modifiers must be one of `Android`, `Fuchsia`, `Mac`,
307 `Mac10.12`, `Mac10.13`, `Mac10.14`, `Mac10.15`, `Mac11`, `Mac11-arm64`,
308 `Linux`, `Trusty`, `Win`, `Win7`, `Win10.20h2`, and, optionally, `Release`,
309 or `Debug`. Check the top of
310 [TestExpectations](../../third_party/blink/web_tests/TestExpectations) or the
311 `ALL_SYSTEMS` macro in
312 [third_party/blink/tools/blinkpy/web_tests/port/base.py](../../third_party/blink/tools/blinkpy/web_tests/port/base.py)
313 for an up-to-date list.
pwnalld8a250722016-11-09 18:24:03314* Some modifiers are meta keywords, e.g. `Win` represents both `Win7` and
Johanne1b8bd502021-11-14 21:06:47315 `Win10.20h2`. See the `CONFIGURATION_SPECIFIER_MACROS` dictionary in
Kent Tamura01019442018-05-01 22:06:58316 [third_party/blink/tools/blinkpy/web_tests/port/base.py](../../third_party/blink/tools/blinkpy/web_tests/port/base.py)
pwnalld8a250722016-11-09 18:24:03317 for the meta keywords and which modifiers they represent.
318* Expectations can be one or more of `Crash`, `Failure`, `Pass`, `Rebaseline`,
Ned Nguyenbd8cc342018-07-19 16:04:29319 `Slow`, `Skip`, `Timeout`, `WontFix`, `Missing`.
Quinten Yearsleyd13299d2017-07-25 17:22:17320 If multiple expectations are listed, the test is considered "flaky" and any
321 of those results will be considered as expected.
pwnalld8a250722016-11-09 18:24:03322
323For example:
324
325```
326crbug.com/12345 [ Win Debug ] fast/html/keygen.html [ Crash ]
327```
328
329which indicates that the "fast/html/keygen.html" test file is expected to crash
330when run in the Debug configuration on Windows, and the tracking bug for this
331crash is bug \#12345 in the [Chromium issue tracker](https://crbug.com). Note
332that the test will still be run, so that we can notice if it doesn't actually
333crash.
334
335Assuming you're running a debug build on Mac 10.9, the following lines are all
336equivalent (in terms of whether the test is performed and its expected outcome):
337
338```
339fast/html/keygen.html [ Skip ]
340fast/html/keygen.html [ WontFix ]
341Bug(darin) [ Mac10.9 Debug ] fast/html/keygen.html [ Skip ]
342```
343
344### Semantics
345
346* `WontFix` implies `Skip` and also indicates that we don't have any plans to
347 make the test pass.
348* `WontFix` lines always go in the
Kent Tamura59ffb022018-11-27 05:30:56349 [NeverFixTests file](../../third_party/blink/web_tests/NeverFixTests) as
pwnalld8a250722016-11-09 18:24:03350 we never intend to fix them. These are just for tests that only apply to some
351 subset of the platforms we support.
352* `WontFix` and `Skip` must be used by themselves and cannot be specified
353 alongside `Crash` or another expectation keyword.
354* `Slow` causes the test runner to give the test 5x the usual time limit to run.
355 `Slow` lines go in the
Kent Tamura59ffb022018-11-27 05:30:56356 [SlowTests file ](../../third_party/blink/web_tests/SlowTests). A given
pwnalld8a250722016-11-09 18:24:03357 line cannot have both Slow and Timeout.
358
359Also, when parsing the file, we use two rules to figure out if an expectation
360line applies to the current run:
361
3621. If the configuration parameters don't match the configuration of the current
363 run, the expectation is ignored.
3642. Expectations that match more of a test name are used before expectations that
365 match less of a test name.
366
367For example, if you had the following lines in your file, and you were running a
368debug build on `Mac10.10`:
369
370```
371crbug.com/12345 [ Mac10.10 ] fast/html [ Failure ]
372crbug.com/12345 [ Mac10.10 ] fast/html/keygen.html [ Pass ]
373crbug.com/12345 [ Win7 ] fast/forms/submit.html [ Failure ]
374crbug.com/12345 fast/html/section-element.html [ Failure Crash ]
375```
376
377You would expect:
378
379* `fast/html/article-element.html` to fail with a text diff (since it is in the
380 fast/html directory).
381* `fast/html/keygen.html` to pass (since the exact match on the test name).
Staphany Park4b66843e2019-07-11 07:28:33382* `fast/forms/submit.html` to pass (since the configuration parameters don't
pwnalld8a250722016-11-09 18:24:03383 match).
384* `fast/html/section-element.html` to either crash or produce a text (or image
385 and text) failure, but not time out or pass.
386
Xianzhu Wang61d49d52021-07-31 16:44:53387Test expectation can also apply to all tests under a directory (specified with a
388name ending with `/*`). A more specific expectation can override a less
389specific expectation. For example:
390```
391crbug.com/12345 virtual/composite-after-paint/* [ Skip ]
392crbug.com/12345 virtual/composite-after-paint/compositing/backface-visibility/* [ Pass ]
393crbug.com/12345 virtual/composite-after-paint/compositing/backface-visibility/test.html [ Failure ]
394```
395
pwnalld8a250722016-11-09 18:24:03396*** promo
397Duplicate expectations are not allowed within the file and will generate
398warnings.
399***
400
401You can verify that any changes you've made to an expectations file are correct
402by running:
403
404```bash
Kent Tamura02b4a5b1f2018-04-24 23:26:28405third_party/blink/tools/lint_test_expectations.py
pwnalld8a250722016-11-09 18:24:03406```
407
408which will cycle through all of the possible combinations of configurations
409looking for problems.