Return to Video

Basics of creating a reftest

  • 0:01 - 0:03
    In the last video, I gave an introduction to reftests.
  • 0:03 - 0:08
    Which is basically just taking 2 web pages, rendering them, and then comparing them visually to see if they match or not.
  • 0:08 - 0:10
    In this video I'll go over how to create your own reftest.
  • 0:10 - 0:14
    So one thing that I wanted to do first is just show you how reftests are run.
  • 0:14 - 0:18
    And we looked at the mach command in the last video, but I just wanted to show you this reftest.py file.
  • 0:18 - 0:25
    So all mach does basically is run this reftest python file with some specified command line parameters.
  • 0:25 - 0:32
    And if we look at this add_options right here
  • 0:32 - 0:36
    we can see there's a bunch of different command line parameters that you can run if you wanted to run these manually.
  • 0:36 - 0:39
    It's a lot easier just to use mach, so I would just stick with that.
  • 0:39 - 0:41
    I'm going to close that.
  • 0:41 - 0:46
    So the first thing you want to do when creating a reftest is to list it in your .list file.
  • 0:46 - 0:54
    So I'm just going to pretend that I want to add it to content/html/content/reftests/reftest.list
  • 0:54 - 0:56
    OK, and I'm going to add it to a new line here.
  • 0:56 - 1:00
    I'm going to start it with == to mean that I want these pages to match.
  • 1:00 - 1:02
    And I'm going to call them test1.html and test2.html
  • 1:02 - 1:06
    The next thing I'm going to do is create 2 files in that directory.
  • 1:06 - 1:08
    One called test1.html
  • 1:08 - 1:15
    And this page is going to be basically a simple html page, and it's going to have strong markup here.
  • 1:15 - 1:17
    Which is basically the same as bold.
  • 1:17 - 1:26
    So what I want to do is compare that this strong element right here is going to match the equivalent b, which is bold element.
  • 1:26 - 1:27
    So that's test1.html.
  • 1:27 - 1:31
    And then I'm going to copy that to test2.html
  • 1:31 - 1:37
    And then I'm going to open test2.html
  • 1:37 - 1:41
    And this strong tag right here, I'm going to change that to bold, to b.
  • 1:41 - 1:44
    Save and quit.
  • 1:44 - 1:48
    So now we created our reftest, it's basically that simple.
  • 1:48 - 1:57
    Now to run it we're going to type mach reftest content/html/content/reftests/reftest.list.
  • 1:57 - 2:00
    So I'm just specifying the list file that I added it to.
  • 2:00 - 2:05
    And I'm going to add a filter here, just so it only runs the one I just added, and not everything in that file.
  • 2:05 - 2:08
    And when I run this, we should see that it's going to be successful.
  • 2:08 - 2:12
    And if we look right up here, we can see that successful is 1.
  • 2:12 - 2:15
    So that passed, which is what we were expecting, so that's good.
  • 2:15 - 2:19
    Now I want to show you what will happen if there's actually a mismatch.
  • 2:19 - 2:21
    So I'm going to open up test2.html
  • 2:21 - 2:25
    And let's just say we took out this b right there.
  • 2:25 - 2:28
    So the first one, if you recall has strong.
  • 2:28 - 2:31
    The second one has no tag, so these should render a little bit differently.
  • 2:31 - 2:33
    And the test should fail
  • 2:33 - 2:34
    So I'm just going to run it again.
  • 2:34 - 2:40
    And if I scroll up here, we'll see unexpected is 1, successful is 0.
  • 2:40 - 2:41
    So yes it definitely did fail.
  • 2:41 - 2:44
    And you can actually just scroll up here a little bit more.
  • 2:44 - 2:47
    And anytime that there's a failure or a mismatch with reftests.
  • 2:47 - 2:52
    You'll see that it gives you the actual data URL of both images.
  • 2:52 - 2:55
    So this is image 1, up here above it.
  • 2:55 - 2:56
    And this is image2 right here.
  • 2:56 - 2:59
    And if you paste those data URLs in a web browser URL bar.
  • 2:59 - 3:02
    You're going to actually see the images rendered.
  • 3:02 - 3:06
    So you can look at it visually to see if you have any intuition of why that test failed.
  • 3:06 - 3:12
    One more thing that I wanted to add, is if you're adding a brand new .list file that doesn't exist yet.
  • 3:12 - 3:17
    The way that reftests work, is that it recursively includes other list files.
  • 3:17 - 3:21
    So the master list file that you want to add to is just layout/reftests/reftest.list
  • 3:21 - 3:26
    And for example if I look for the reftest [list] that I had
  • 3:26 - 3:31
    content/htmlcontent... reftest.list you can find it right there.
  • 3:31 - 3:32
    I'm going to quit.
  • 3:32 - 3:35
    And that's all I wanted to show you for this video.
Title:
Basics of creating a reftest
Description:

Firefox development tutorial showing you how to create an automated reftest
http://codefirefox.com

more » « less
Video Language:
English

English subtitles

Revisions