wiki:Writing Reftests

Version 4 (modified by hayato@chromium.org, 10 years ago) (diff)

--

Writing Reftests

Reftests is not supported yet in WebKit. Please see https://bugs.webkit.org/show_bug.cgi?id=36065 for the current status.

Reftests in WebKit

Reftests use a HTML file ('-expected.html') to represent an expected rendering result, instead of pre-generated expected files, such as '-expected.txt', '-expected.checksum' and '-expected.png'.

Let's see the following sample reftest.

  • hello.html
    <html><head><title>reftest0001</title>
    <body><strong>Hello!</strong></body>
    </html>
    
  • hello-expected.html
    <html><head><title>reftest0001</title>
    <body><b>Hello!</b></body>
    </html>
    

A new-run-webkit-tests recognizes this is a reftest and run the test as if this is a normal layout test. You can think that a '-expected.html' file is used to produce '-expected.checksum' and '-expected.png' on the fly. If there is a difference between the rendering results of two html files, the test fails.

Screenshot: Todo

There is yet another type of reftests, 'a mismatch reftest'.

Let's see the following sample 'mismatch' reftest.

  • foo.html
    <html><head><title>reftest0001</title>
    <body><strong>Hello!</strong></body>
    </html>
    
  • foo-expected-mismatch.html
    <html><head><title>reftest0001</title>
    <body>Hello!</body>
    </html>
    

In this case, the test fails if both produces the same results. The test passes if there is any differences between them.

Screenshot: Todo

Naming convention

  • (normal) reftests: {testname}.html and {testname}-expected.html
  • 'mismatch' reftests: {testname}.html and {testname}-expected-mismatch.html

FAQ

  • Q. Can we use a platform-specific expected html file?
  • A. Yes. Reftests try to obey the current layout test mechanism as possible as we can.
  • Q. What happens if we 'rebase' for reftests?
  • A. A 'Rebasing' doesn't make sense in reftests. A rebase line tool simply skips reftests.
  • Q. If we have hello.html, hello-expected.html and hello-expected-mismatch.html files, what happens? Does that run two reftests?
  • A. No. That should be considerd a wrong configuration. Please don't use one test file for a (normal) reftest and a 'mismatch' reftest. Please choose the different test name for each test.
  • Q. Can we use '-expected.html' and '-expected.{checksum,png}' at the same time for one test file?
  • A. No.
  • Q. What kind of failures reftests produce?
  • A. If an image comparison failure happens in reftests, that is marked as a 'IMAGE' failure. If either of two html files crashes, it is considered as 'CRASH'. So does 'TIMEOUT'.

References