bslatkin/dpxdt — pull request #90 by danvk (2014-07-26 06:57:48+00:00)
Title: A tool to run local perceptual diffs

This is a proof of concept for a local pdiff test using dpxdt.

Here's the usage:

$ ./dpxdt/tools/local_pdiff.py test dpxdt/tools/local_pdiff_demo
homepage: Running webpage capture process
homepage: Resizing reference image
homepage: Running perceptual diff process
homepage passed (no diff)
different-text: Running webpage capture process
different-text: Resizing reference image
different-text: Running perceptual diff process
different-text passed (no diff)

If you add a box shadow or something to `dpxdt/tools/local_pdiff_demo/index.html` and rerun:

$ ./dpxdt/tools/local_pdiff.py test dpxdt/tools/local_pdiff_demo
homepage: Running webpage capture process
homepage: Resizing reference image
homepage: Running perceptual diff process
homepage failed
0.0103501 distortion
See /var/folders/9q/340_463n2fvbzjg232s3hrt00000gn/T/tmpNVxkQK/tmpUXP6UC/diff.png
different-text: Running webpage capture process
different-text: Resizing reference image
different-text: Running perceptual diff process
different-text failed
0.0103501 distortion
See /var/folders/9q/340_463n2fvbzjg232s3hrt00000gn/T/tmpNVxkQK/tmpiolKAG/diff.png

... and then you can update the reference images:

$ ./dpxdt/tools/local_pdiff.py update dpxdt/tools/local_pdiff_demo
homepage: Running webpage capture process
homepage: Updated dpxdt/tools/local_pdiff_demo/homepage.png
different-text: Running webpage capture process
different-text: Updated dpxdt/tools/local_pdiff_demo/different-text.png

Thoughts much appreciated! If this is on the right track, I can add tests and such. There's definitely some duplicated code that could be consolidated, too.