hadley/ggplot2 — pull request #442 by wch (2012-03-15 04:50:06+00:00)
Title: Visual test system

This is very preliminary, so I'm just looking for comments and suggestions. Many of the changes are just moved files. The new functions are in `visual-test.r`. The files `aspect-ratio.r` and `dotplot.r` have been converted to the new system, so take a look at them for examples of how to use it.

You can try it out by doing the following. Fetch and checkout the branch:

```
git fetch https://github.com/wch/ggplot2.git visual-test
git checkout FETCH_HEAD
```

In your R session, starting in the ggplot2 dir:

```R
# I think this is needed for consistent output across platforms
# If asked, agree to download and install gtk+ (~56MB for Mac)
install.packages('cairoDevice')

library(devtools)
dev_mode()
load_all('.')
source('visual_test/aspect-ratio.r')
source('visual_test/dotplot.r')
```

Output files will go in `visual_test/aspect-ratio/` and `visual_test/dotplot/`. In each of these dirs there is a index.html page that shows all the tests, with descriptions. In the future, everything in these directories will be committed to the repo.

Still needs to be done:

* Convert the rest of the visual tests to the new system
* Write a single function that will run all tests
* Create a top-level webpage with links to each page of tests
* Write code to generate visual diffs between commits

Open questions:

* Use optipng to shrink output files?
* Pro: smaller file size - visual tests may add up over time. Even minor changes to, say, tick marks, padding, or automatic breaks will result in an entirely new set of test files. Example: for the dotplot tests, total size is 440,934 bytes vs. 189,408 bytes after using optipng.
* Con: it adds an external dependency.
* Use smaller images? Presently the default size is 4x4 inches at 72 ppi, or 288x288 pixels.

Now that I think of it, this is probably a good candidate for using a git submodule. All the visual test results could go in the submodule.