blob: 2023fbd03268e9ac21df5080f9e26b86fd7d0275 [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
19For any of these types of tests, there are files checked into the LayoutTests
20directory named `-expected.{txt,png,wav}`. Lastly, we also support the concept
21of "reference tests", which check that two pages are rendered identically
22(pixel-by-pixel). As long as the two tests' output match, the tests pass. For
23more on reference tests, see
24[Writing ref tests](https://trac.webkit.org/wiki/Writing%20Reftests).
25
26## Failing tests
27
28When the output doesn't match, there are two potential reasons for it:
29
30* The port is performing "correctly", but the output simply won't match the
31 generic version. The usual reason for this is for things like form controls,
32 which are rendered differently on each platform.
33* The port is performing "incorrectly" (i.e., the test is failing).
34
35In both cases, the convention is to check in a new baseline (aka rebaseline),
36even though that file may be codifying errors. This helps us maintain test
37coverage for all the other things the test is testing while we resolve the bug.
38
39*** promo
40If a test can be rebaselined, it should always be rebaselined instead of adding
41lines to TestExpectations.
42***
43
44Bugs at [crbug.com](https://crbug.com) should track fixing incorrect behavior,
45not lines in
46[TestExpectations](../../third_party/WebKit/LayoutTests/TestExpectations). If a
47test is never supposed to pass (e.g. it's testing Windows-specific behavior, so
48can't ever pass on Linux/Mac), move it to the
49[NeverFixTests](../../third_party/WebKit/LayoutTests/NeverFixTests) file. That
50gets it out of the way of the rest of the project.
51
52There are some cases where you can't rebaseline and, unfortunately, we don't
53have a better solution than either:
54
551. Reverting the patch that caused the failure, or
562. Adding a line to TestExpectations and fixing the bug later.
57
58In this case, **reverting the patch is strongly preferred**.
59
60These are the cases where you can't rebaseline:
61
62* The test is a reference test.
63* The test gives different output in release and debug; in this case, generate a
64 baseline with the release build, and mark the debug build as expected to fail.
65* The test is flaky, crashes or times out.
66* The test is for a feature that hasn't yet shipped on some platforms yet, but
67 will shortly.
68
69## Handling flaky tests
70
71The
72[flakiness dashboard](https://test-results.appspot.com/dashboards/flakiness_dashboard.html)
73is a tool for understanding a test’s behavior over time.
74Originally designed for managing flaky tests, the dashboard shows a timeline
75view of the test’s behavior over time. The tool may be overwhelming at first,
76but
77[the documentation](https://dev.chromium.org/developers/testing/flakiness-dashboard)
78should help. Once you decide that a test is truly flaky, you can suppress it
79using the TestExpectations file, as described below.
80
81We do not generally expect Chromium sheriffs to spend time trying to address
82flakiness, though.
83
84## How to rebaseline
85
86Since baselines themselves are often platform-specific, updating baselines in
87general requires fetching new test results after running the test on multiple
88platforms.
89
90### Rebaselining using try jobs
91
92The recommended way to rebaseline for a currently-in-progress CL is to use
Quinten Yearsleya58f83c2017-05-30 16:00:5793results from try jobs, by using the command-tool
94`third_party/WebKit/Tools/Scripts/webkit-patch rebaseline-cl`:
pwnalld8a250722016-11-09 18:24:0395
Quinten Yearsleya58f83c2017-05-30 16:00:57961. First, upload a CL.
97 There is no need to add `[ NeedsRebaseline ]` lines in TestExpectations for
98 tests that are rebaselined by this method.
992. Trigger try jobs by running `webkit-patch rebaseline-cl`. This should
100 trigger jobs on
pwnalld8a250722016-11-09 18:24:03101 [tryserver.blink](https://build.chromium.org/p/tryserver.blink/builders).
pwnalld8a250722016-11-09 18:24:031023. Wait for all try jobs to finish.
Quinten Yearsleya58f83c2017-05-30 16:00:571034. Run `webkit-patch rebaseline-cl` again to fetch new baselines.
104 By default, this will download new baselines for any failing tests
105 in the try jobs.
106 (Run `webkit-patch rebaseline-cl --help` for more specific options.)
pwnalld8a250722016-11-09 18:24:031075. Commit the new baselines and upload a new patch.
108
109This way, the new baselines can be reviewed along with the changes, which helps
110the reviewer verify that the new baselines are correct. It also means that there
111is no period of time when the layout test results are ignored.
112
Quinten Yearsleya58f83c2017-05-30 16:00:57113#### Options
114
pwnalld8a250722016-11-09 18:24:03115The tests which `webkit-patch rebaseline-cl` tries to download new baselines for
116depends on its arguments.
117
118* By default, it tries to download all baselines for tests that failed in the
119 try jobs.
120* If you pass `--only-changed-tests`, then only tests modified in the CL will be
121 considered.
122* You can also explicitly pass a list of test names, and then just those tests
123 will be rebaselined.
Quinten Yearsleya58f83c2017-05-30 16:00:57124* If some of the try jobs failed to run, and you wish to continue rebaselining
125 assuming that there are no platform-specific results for those platforms,
126 you can add the flag `--fill-missing`.
pwnalld8a250722016-11-09 18:24:03127
128### Rebaselining with rebaseline-o-matic
129
130If the test is not already listed in
131[TestExpectations](../../third_party/WebKit/LayoutTests/TestExpectations), you
132can mark it as `[ NeedsRebaseline ]`. The
133[rebaseline-o-matic bot](https://build.chromium.org/p/chromium.infra.cron/builders/rebaseline-o-matic)
134will automatically detect when the bots have cycled (by looking at the blame on
135the file) and do the rebaseline for you. As long as the test doesn't timeout or
136crash, it won't turn the bots red if it has a `NeedsRebaseline` expectation.
137When all of the continuous builders on the waterfall have cycled, the
138rebaseline-o-matic bot will commit a patch which includes the new baselines and
139removes the `[ NeedsRebaseline ]` entry from TestExpectations.
140
141### Rebaselining manually
142
1431. If the tests is already listed in TestExpectations as flaky, mark the test
144 `NeedsManualRebaseline` and comment out the flaky line so that your patch can
145 land without turning the tree red. If the test is not in TestExpectations,
146 you can add a `[ Rebaseline ]` line to TestExpectations.
1472. Run `third_party/WebKit/Tools/Scripts/webkit-patch rebaseline-expectations`
1483. Post the patch created in step 2 for review.
149
150## Kinds of expectations files
151
152* [TestExpectations](../../third_party/WebKit/LayoutTests/TestExpectations): The
153 main test failure suppression file. In theory, this should be used for flaky
154 lines and `NeedsRebaseline`/`NeedsManualRebaseline` lines.
155* [ASANExpectations](../../third_party/WebKit/LayoutTests/ASANExpectations):
156 Tests that fail under ASAN.
157* [LeakExpectations](../../third_party/WebKit/LayoutTests/LeakExpectations):
158 Tests that have memory leaks under the leak checker.
159* [MSANExpectations](../../third_party/WebKit/LayoutTests/MSANExpectations):
160 Tests that fail under MSAN.
161* [NeverFixTests](../../third_party/WebKit/LayoutTests/NeverFixTests): Tests
162 that we never intend to fix (e.g. a test for Windows-specific behavior will
163 never be fixed on Linux/Mac). Tests that will never pass on any platform
164 should just be deleted, though.
165* [SlowTests](../../third_party/WebKit/LayoutTests/SlowTests): Tests that take
166 longer than the usual timeout to run. Slow tests are given 5x the usual
167 timeout.
168* [SmokeTests](../../third_party/WebKit/LayoutTests/SmokeTests): A small subset
169 of tests that we run on the Android bot.
170* [StaleTestExpectations](../../third_party/WebKit/LayoutTests/StaleTestExpectations):
171 Platform-specific lines that have been in TestExpectations for many months.
172 They're moved here to get them out of the way of people doing rebaselines
173 since they're clearly not getting fixed anytime soon.
174* [W3CImportExpectations](../../third_party/WebKit/LayoutTests/W3CImportExpectations):
175 A record of which W3C tests should be imported or skipped.
pwnalld8a250722016-11-09 18:24:03176
177### Flag-specific expectations files
178
179It is possible to handle tests that only fail when run with a particular flag
180being passed to `content_shell`. See
181[LayoutTests/FlagExpectations/README.txt](../../third_party/WebKit/LayoutTests/FlagExpectations/README.txt)
182for more.
183
184## Updating the expectations files
185
186### Ordering
187
188The file is not ordered. If you put new changes somewhere in the middle of the
189file, this will reduce the chance of merge conflicts when landing your patch.
190
191### Syntax
192
193The syntax of the file is roughly one expectation per line. An expectation can
194apply to either a directory of tests, or a specific tests. Lines prefixed with
195`# ` are treated as comments, and blank lines are allowed as well.
196
197The syntax of a line is roughly:
198
199```
200[ bugs ] [ "[" modifiers "]" ] test_name [ "[" expectations "]" ]
201```
202
203* Tokens are separated by whitespace.
204* **The brackets delimiting the modifiers and expectations from the bugs and the
205 test_name are not optional**; however the modifiers component is optional. In
206 other words, if you want to specify modifiers or expectations, you must
207 enclose them in brackets.
208* Lines are expected to have one or more bug identifiers, and the linter will
209 complain about lines missing them. Bug identifiers are of the form
210 `crbug.com/12345`, `code.google.com/p/v8/issues/detail?id=12345` or
211 `Bug(username)`.
212* If no modifiers are specified, the test applies to all of the configurations
213 applicable to that file.
214* Modifiers can be one or more of `Mac`, `Mac10.9`, `Mac10.10`, `Mac10.11`,
215 `Retina`, `Win`, `Win7`, `Win10`, `Linux`, `Linux32`, `Precise`, `Trusty`,
216 `Android`, `Release`, `Debug`.
217* Some modifiers are meta keywords, e.g. `Win` represents both `Win7` and
218 `Win10`. See the `CONFIGURATION_SPECIFIER_MACROS` dictionary in
219 [third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py](../../third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py)
220 for the meta keywords and which modifiers they represent.
221* Expectations can be one or more of `Crash`, `Failure`, `Pass`, `Rebaseline`,
222 `Slow`, `Skip`, `Timeout`, `WontFix`, `Missing`, `NeedsRebaseline`,
223 `NeedsManualRebaseline`. If multiple expectations are listed, the test is
224 considered "flaky" and any of those results will be considered as expected.
225
226For example:
227
228```
229crbug.com/12345 [ Win Debug ] fast/html/keygen.html [ Crash ]
230```
231
232which indicates that the "fast/html/keygen.html" test file is expected to crash
233when run in the Debug configuration on Windows, and the tracking bug for this
234crash is bug \#12345 in the [Chromium issue tracker](https://crbug.com). Note
235that the test will still be run, so that we can notice if it doesn't actually
236crash.
237
238Assuming you're running a debug build on Mac 10.9, the following lines are all
239equivalent (in terms of whether the test is performed and its expected outcome):
240
241```
242fast/html/keygen.html [ Skip ]
243fast/html/keygen.html [ WontFix ]
244Bug(darin) [ Mac10.9 Debug ] fast/html/keygen.html [ Skip ]
245```
246
247### Semantics
248
249* `WontFix` implies `Skip` and also indicates that we don't have any plans to
250 make the test pass.
251* `WontFix` lines always go in the
252 [NeverFixTests file]((../../third_party/WebKit/LayoutTests/NeverFixTests) as
253 we never intend to fix them. These are just for tests that only apply to some
254 subset of the platforms we support.
255* `WontFix` and `Skip` must be used by themselves and cannot be specified
256 alongside `Crash` or another expectation keyword.
257* `Slow` causes the test runner to give the test 5x the usual time limit to run.
258 `Slow` lines go in the
259 [SlowTests file ](../../third_party/WebKit/LayoutTests/SlowTests). A given
260 line cannot have both Slow and Timeout.
261
262Also, when parsing the file, we use two rules to figure out if an expectation
263line applies to the current run:
264
2651. If the configuration parameters don't match the configuration of the current
266 run, the expectation is ignored.
2672. Expectations that match more of a test name are used before expectations that
268 match less of a test name.
269
270For example, if you had the following lines in your file, and you were running a
271debug build on `Mac10.10`:
272
273```
274crbug.com/12345 [ Mac10.10 ] fast/html [ Failure ]
275crbug.com/12345 [ Mac10.10 ] fast/html/keygen.html [ Pass ]
276crbug.com/12345 [ Win7 ] fast/forms/submit.html [ Failure ]
277crbug.com/12345 fast/html/section-element.html [ Failure Crash ]
278```
279
280You would expect:
281
282* `fast/html/article-element.html` to fail with a text diff (since it is in the
283 fast/html directory).
284* `fast/html/keygen.html` to pass (since the exact match on the test name).
285* `fast/html/submit.html` to pass (since the configuration parameters don't
286 match).
287* `fast/html/section-element.html` to either crash or produce a text (or image
288 and text) failure, but not time out or pass.
289
290*** promo
291Duplicate expectations are not allowed within the file and will generate
292warnings.
293***
294
295You can verify that any changes you've made to an expectations file are correct
296by running:
297
298```bash
299third_party/WebKit/Tools/Scripts/lint-test-expectations
300```
301
302which will cycle through all of the possible combinations of configurations
303looking for problems.