blob: e4cbf9c9f8604582b39fb27f13813876ec1001e8 [file] [log] [blame] [view]
pwnalld8a250722016-11-09 18:24:031# Layout Test Expectations and Baselines
2
3
4The primary function of the LayoutTests is as a regression test suite; this
5means 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
11All layout tests have "expected results", or "baselines", which may be one of
12several 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
Robert Ma06f7acc2017-11-14 17:55:4719For any of these types of tests, baselines are checked into the LayoutTests
20directory. 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
24[Layout Test Baseline Fallback](layout_test_baseline_fallback.md) for more
25details.
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
52[TestExpectations](../../third_party/WebKit/LayoutTests/TestExpectations). If a
53test 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
55[NeverFixTests](../../third_party/WebKit/LayoutTests/NeverFixTests) file. That
56gets 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
100`third_party/WebKit/Tools/Scripts/webkit-patch rebaseline-cl`:
pwnalld8a250722016-11-09 18:24:03101
Quinten Yearsleya58f83c2017-05-30 16:00:571021. First, upload a CL.
Quinten Yearsleya58f83c2017-05-30 16:00:571032. Trigger try jobs by running `webkit-patch rebaseline-cl`. This should
104 trigger jobs on
pwnalld8a250722016-11-09 18:24:03105 [tryserver.blink](https://build.chromium.org/p/tryserver.blink/builders).
pwnalld8a250722016-11-09 18:24:031063. Wait for all try jobs to finish.
Quinten Yearsleya58f83c2017-05-30 16:00:571074. Run `webkit-patch rebaseline-cl` again to fetch new baselines.
108 By default, this will download new baselines for any failing tests
109 in the try jobs.
110 (Run `webkit-patch rebaseline-cl --help` for more specific options.)
pwnalld8a250722016-11-09 18:24:031115. Commit the new baselines and upload a new patch.
112
113This way, the new baselines can be reviewed along with the changes, which helps
114the reviewer verify that the new baselines are correct. It also means that there
115is no period of time when the layout test results are ignored.
116
Quinten Yearsleya58f83c2017-05-30 16:00:57117#### Options
118
Quinten Yearsleyd13299d2017-07-25 17:22:17119### Rebaselining with try jobs
120
pwnalld8a250722016-11-09 18:24:03121The tests which `webkit-patch rebaseline-cl` tries to download new baselines for
122depends on its arguments.
123
124* By default, it tries to download all baselines for tests that failed in the
125 try jobs.
126* If you pass `--only-changed-tests`, then only tests modified in the CL will be
127 considered.
128* You can also explicitly pass a list of test names, and then just those tests
129 will be rebaselined.
Quinten Yearsleya58f83c2017-05-30 16:00:57130* If some of the try jobs failed to run, and you wish to continue rebaselining
131 assuming that there are no platform-specific results for those platforms,
132 you can add the flag `--fill-missing`.
pwnalld8a250722016-11-09 18:24:03133
pwnalld8a250722016-11-09 18:24:03134### Rebaselining manually
135
1361. If the tests is already listed in TestExpectations as flaky, mark the test
137 `NeedsManualRebaseline` and comment out the flaky line so that your patch can
138 land without turning the tree red. If the test is not in TestExpectations,
139 you can add a `[ Rebaseline ]` line to TestExpectations.
1402. Run `third_party/WebKit/Tools/Scripts/webkit-patch rebaseline-expectations`
1413. Post the patch created in step 2 for review.
142
143## Kinds of expectations files
144
145* [TestExpectations](../../third_party/WebKit/LayoutTests/TestExpectations): The
Quinten Yearsleyd13299d2017-07-25 17:22:17146 main test failure suppression file. In theory, this should be used for
147 temporarily marking tests as flaky.
pwnalld8a250722016-11-09 18:24:03148* [ASANExpectations](../../third_party/WebKit/LayoutTests/ASANExpectations):
149 Tests that fail under ASAN.
150* [LeakExpectations](../../third_party/WebKit/LayoutTests/LeakExpectations):
151 Tests that have memory leaks under the leak checker.
152* [MSANExpectations](../../third_party/WebKit/LayoutTests/MSANExpectations):
153 Tests that fail under MSAN.
154* [NeverFixTests](../../third_party/WebKit/LayoutTests/NeverFixTests): Tests
155 that we never intend to fix (e.g. a test for Windows-specific behavior will
156 never be fixed on Linux/Mac). Tests that will never pass on any platform
157 should just be deleted, though.
158* [SlowTests](../../third_party/WebKit/LayoutTests/SlowTests): Tests that take
159 longer than the usual timeout to run. Slow tests are given 5x the usual
160 timeout.
161* [SmokeTests](../../third_party/WebKit/LayoutTests/SmokeTests): A small subset
162 of tests that we run on the Android bot.
163* [StaleTestExpectations](../../third_party/WebKit/LayoutTests/StaleTestExpectations):
164 Platform-specific lines that have been in TestExpectations for many months.
165 They're moved here to get them out of the way of people doing rebaselines
166 since they're clearly not getting fixed anytime soon.
167* [W3CImportExpectations](../../third_party/WebKit/LayoutTests/W3CImportExpectations):
168 A record of which W3C tests should be imported or skipped.
pwnalld8a250722016-11-09 18:24:03169
170### Flag-specific expectations files
171
172It is possible to handle tests that only fail when run with a particular flag
173being passed to `content_shell`. See
174[LayoutTests/FlagExpectations/README.txt](../../third_party/WebKit/LayoutTests/FlagExpectations/README.txt)
175for more.
176
177## Updating the expectations files
178
179### Ordering
180
181The file is not ordered. If you put new changes somewhere in the middle of the
182file, this will reduce the chance of merge conflicts when landing your patch.
183
184### Syntax
185
186The syntax of the file is roughly one expectation per line. An expectation can
187apply to either a directory of tests, or a specific tests. Lines prefixed with
188`# ` are treated as comments, and blank lines are allowed as well.
189
190The syntax of a line is roughly:
191
192```
193[ bugs ] [ "[" modifiers "]" ] test_name [ "[" expectations "]" ]
194```
195
196* Tokens are separated by whitespace.
197* **The brackets delimiting the modifiers and expectations from the bugs and the
198 test_name are not optional**; however the modifiers component is optional. In
199 other words, if you want to specify modifiers or expectations, you must
200 enclose them in brackets.
201* Lines are expected to have one or more bug identifiers, and the linter will
202 complain about lines missing them. Bug identifiers are of the form
203 `crbug.com/12345`, `code.google.com/p/v8/issues/detail?id=12345` or
204 `Bug(username)`.
205* If no modifiers are specified, the test applies to all of the configurations
206 applicable to that file.
207* Modifiers can be one or more of `Mac`, `Mac10.9`, `Mac10.10`, `Mac10.11`,
208 `Retina`, `Win`, `Win7`, `Win10`, `Linux`, `Linux32`, `Precise`, `Trusty`,
209 `Android`, `Release`, `Debug`.
210* Some modifiers are meta keywords, e.g. `Win` represents both `Win7` and
211 `Win10`. See the `CONFIGURATION_SPECIFIER_MACROS` dictionary in
212 [third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py](../../third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py)
213 for the meta keywords and which modifiers they represent.
214* Expectations can be one or more of `Crash`, `Failure`, `Pass`, `Rebaseline`,
Quinten Yearsleyd13299d2017-07-25 17:22:17215 `Slow`, `Skip`, `Timeout`, `WontFix`, `Missing`, `NeedsManualRebaseline`.
216 If multiple expectations are listed, the test is considered "flaky" and any
217 of those results will be considered as expected.
pwnalld8a250722016-11-09 18:24:03218
219For example:
220
221```
222crbug.com/12345 [ Win Debug ] fast/html/keygen.html [ Crash ]
223```
224
225which indicates that the "fast/html/keygen.html" test file is expected to crash
226when run in the Debug configuration on Windows, and the tracking bug for this
227crash is bug \#12345 in the [Chromium issue tracker](https://crbug.com). Note
228that the test will still be run, so that we can notice if it doesn't actually
229crash.
230
231Assuming you're running a debug build on Mac 10.9, the following lines are all
232equivalent (in terms of whether the test is performed and its expected outcome):
233
234```
235fast/html/keygen.html [ Skip ]
236fast/html/keygen.html [ WontFix ]
237Bug(darin) [ Mac10.9 Debug ] fast/html/keygen.html [ Skip ]
238```
239
240### Semantics
241
242* `WontFix` implies `Skip` and also indicates that we don't have any plans to
243 make the test pass.
244* `WontFix` lines always go in the
Robert Ma89dd91d832017-08-02 18:08:44245 [NeverFixTests file](../../third_party/WebKit/LayoutTests/NeverFixTests) as
pwnalld8a250722016-11-09 18:24:03246 we never intend to fix them. These are just for tests that only apply to some
247 subset of the platforms we support.
248* `WontFix` and `Skip` must be used by themselves and cannot be specified
249 alongside `Crash` or another expectation keyword.
250* `Slow` causes the test runner to give the test 5x the usual time limit to run.
251 `Slow` lines go in the
252 [SlowTests file ](../../third_party/WebKit/LayoutTests/SlowTests). A given
253 line cannot have both Slow and Timeout.
254
255Also, when parsing the file, we use two rules to figure out if an expectation
256line applies to the current run:
257
2581. If the configuration parameters don't match the configuration of the current
259 run, the expectation is ignored.
2602. Expectations that match more of a test name are used before expectations that
261 match less of a test name.
262
263For example, if you had the following lines in your file, and you were running a
264debug build on `Mac10.10`:
265
266```
267crbug.com/12345 [ Mac10.10 ] fast/html [ Failure ]
268crbug.com/12345 [ Mac10.10 ] fast/html/keygen.html [ Pass ]
269crbug.com/12345 [ Win7 ] fast/forms/submit.html [ Failure ]
270crbug.com/12345 fast/html/section-element.html [ Failure Crash ]
271```
272
273You would expect:
274
275* `fast/html/article-element.html` to fail with a text diff (since it is in the
276 fast/html directory).
277* `fast/html/keygen.html` to pass (since the exact match on the test name).
278* `fast/html/submit.html` to pass (since the configuration parameters don't
279 match).
280* `fast/html/section-element.html` to either crash or produce a text (or image
281 and text) failure, but not time out or pass.
282
283*** promo
284Duplicate expectations are not allowed within the file and will generate
285warnings.
286***
287
288You can verify that any changes you've made to an expectations file are correct
289by running:
290
291```bash
292third_party/WebKit/Tools/Scripts/lint-test-expectations
293```
294
295which will cycle through all of the possible combinations of configurations
296looking for problems.