GM self-test: add --writePath and --mismatchPath , but in a way that works cross-platform

R=scroggo@google.com

Review URL: https://codereview.chromium.org/15085007

git-svn-id: http://skia.googlecode.com/svn/trunk@9077 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/tests/outputs/compared-against-different-pixels-images/output-expected/command_line b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/command_line
index 8b4bf99..397c6b3 100644
--- a/gm/tests/outputs/compared-against-different-pixels-images/output-expected/command_line
+++ b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/command_line
@@ -1 +1 @@
-out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/images/different-pixels --writeJsonSummaryPath gm/tests/outputs/compared-against-different-pixels-images/output-actual/json-summary.txt
+out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/images/different-pixels --writeJsonSummaryPath gm/tests/outputs/compared-against-different-pixels-images/output-actual/json-summary.txt --writePath gm/tests/outputs/compared-against-different-pixels-images/output-actual/writePath --mismatchPath gm/tests/outputs/compared-against-different-pixels-images/output-actual/mismatchPath
diff --git a/gm/tests/outputs/compared-against-different-pixels-images/output-expected/mismatchPath/565/bogusfile b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/mismatchPath/565/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/mismatchPath/565/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/compared-against-different-pixels-images/output-expected/mismatchPath/565/selftest1.png b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/mismatchPath/565/selftest1.png
new file mode 100644
index 0000000..4d6827c
--- /dev/null
+++ b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/mismatchPath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-different-pixels-images/output-actual/mismatchPath/565/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-different-pixels-images/output-expected/mismatchPath/8888/bogusfile b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/mismatchPath/8888/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/mismatchPath/8888/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/compared-against-different-pixels-images/output-expected/mismatchPath/8888/selftest1.png b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/mismatchPath/8888/selftest1.png
new file mode 100644
index 0000000..6784b25
--- /dev/null
+++ b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/mismatchPath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-different-pixels-images/output-actual/mismatchPath/8888/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-different-pixels-images/output-expected/stdout b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/stdout
index 817fc87..c80ad62 100644
--- a/gm/tests/outputs/compared-against-different-pixels-images/output-expected/stdout
+++ b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/stdout
@@ -1,5 +1,7 @@
 GM: These configs will be run: 8888 565
 GM: reading from gm/tests/inputs/images/different-pixels
+GM: writing to gm/tests/outputs/compared-against-different-pixels-images/output-actual/writePath
+GM: writing mismatches to gm/tests/outputs/compared-against-different-pixels-images/output-actual/mismatchPath
 GM: drawing... selftest1 [300 200]
 GM: Ran 1 GMs
 GM: ... over  2 configs ["8888", "565"]
diff --git a/gm/tests/outputs/compared-against-different-pixels-images/output-expected/writePath/565/selftest1.png b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/writePath/565/selftest1.png
new file mode 100644
index 0000000..b3464d0
--- /dev/null
+++ b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/writePath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-different-pixels-images/output-actual/writePath/565/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-different-pixels-images/output-expected/writePath/8888/selftest1.png b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/writePath/8888/selftest1.png
new file mode 100644
index 0000000..db19da5
--- /dev/null
+++ b/gm/tests/outputs/compared-against-different-pixels-images/output-expected/writePath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-different-pixels-images/output-actual/writePath/8888/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-different-pixels-json/output-expected/command_line b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/command_line
index 73227a9..a455456 100644
--- a/gm/tests/outputs/compared-against-different-pixels-json/output-expected/command_line
+++ b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/command_line
@@ -1 +1 @@
-out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/json/different-pixels.json --writeJsonSummaryPath gm/tests/outputs/compared-against-different-pixels-json/output-actual/json-summary.txt
+out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/json/different-pixels.json --writeJsonSummaryPath gm/tests/outputs/compared-against-different-pixels-json/output-actual/json-summary.txt --writePath gm/tests/outputs/compared-against-different-pixels-json/output-actual/writePath --mismatchPath gm/tests/outputs/compared-against-different-pixels-json/output-actual/mismatchPath
diff --git a/gm/tests/outputs/compared-against-different-pixels-json/output-expected/mismatchPath/565/bogusfile b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/mismatchPath/565/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/mismatchPath/565/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/compared-against-different-pixels-json/output-expected/mismatchPath/565/selftest1.png b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/mismatchPath/565/selftest1.png
new file mode 100644
index 0000000..f89763b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/mismatchPath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-different-pixels-json/output-actual/mismatchPath/565/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-different-pixels-json/output-expected/mismatchPath/8888/bogusfile b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/mismatchPath/8888/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/mismatchPath/8888/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/compared-against-different-pixels-json/output-expected/mismatchPath/8888/selftest1.png b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/mismatchPath/8888/selftest1.png
new file mode 100644
index 0000000..e80f342
--- /dev/null
+++ b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/mismatchPath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-different-pixels-json/output-actual/mismatchPath/8888/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-different-pixels-json/output-expected/stdout b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/stdout
index 9a299c5..f17bde6 100644
--- a/gm/tests/outputs/compared-against-different-pixels-json/output-expected/stdout
+++ b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/stdout
@@ -1,5 +1,7 @@
 GM: These configs will be run: 8888 565
 GM: reading expectations from JSON summary file gm/tests/inputs/json/different-pixels.json
+GM: writing to gm/tests/outputs/compared-against-different-pixels-json/output-actual/writePath
+GM: writing mismatches to gm/tests/outputs/compared-against-different-pixels-json/output-actual/mismatchPath
 GM: drawing... selftest1 [300 200]
 GM: Ran 1 GMs
 GM: ... over  2 configs ["8888", "565"]
diff --git a/gm/tests/outputs/compared-against-different-pixels-json/output-expected/writePath/565/selftest1.png b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/writePath/565/selftest1.png
new file mode 100644
index 0000000..cde22a6
--- /dev/null
+++ b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/writePath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-different-pixels-json/output-actual/writePath/565/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-different-pixels-json/output-expected/writePath/8888/selftest1.png b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/writePath/8888/selftest1.png
new file mode 100644
index 0000000..a9e26cf
--- /dev/null
+++ b/gm/tests/outputs/compared-against-different-pixels-json/output-expected/writePath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-different-pixels-json/output-actual/writePath/8888/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-empty-dir/output-expected/command_line b/gm/tests/outputs/compared-against-empty-dir/output-expected/command_line
index 4151af3..48d12f8 100644
--- a/gm/tests/outputs/compared-against-empty-dir/output-expected/command_line
+++ b/gm/tests/outputs/compared-against-empty-dir/output-expected/command_line
@@ -1 +1 @@
-out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/images/empty-dir --writeJsonSummaryPath gm/tests/outputs/compared-against-empty-dir/output-actual/json-summary.txt
+out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/images/empty-dir --writeJsonSummaryPath gm/tests/outputs/compared-against-empty-dir/output-actual/json-summary.txt --writePath gm/tests/outputs/compared-against-empty-dir/output-actual/writePath --mismatchPath gm/tests/outputs/compared-against-empty-dir/output-actual/mismatchPath
diff --git a/gm/tests/outputs/compared-against-empty-dir/output-expected/mismatchPath/565/bogusfile b/gm/tests/outputs/compared-against-empty-dir/output-expected/mismatchPath/565/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-empty-dir/output-expected/mismatchPath/565/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/compared-against-empty-dir/output-expected/mismatchPath/8888/bogusfile b/gm/tests/outputs/compared-against-empty-dir/output-expected/mismatchPath/8888/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-empty-dir/output-expected/mismatchPath/8888/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/compared-against-empty-dir/output-expected/stdout b/gm/tests/outputs/compared-against-empty-dir/output-expected/stdout
index d5a1ada..232baf9 100644
--- a/gm/tests/outputs/compared-against-empty-dir/output-expected/stdout
+++ b/gm/tests/outputs/compared-against-empty-dir/output-expected/stdout
@@ -1,5 +1,7 @@
 GM: These configs will be run: 8888 565
 GM: reading from gm/tests/inputs/images/empty-dir
+GM: writing to gm/tests/outputs/compared-against-empty-dir/output-actual/writePath
+GM: writing mismatches to gm/tests/outputs/compared-against-empty-dir/output-actual/mismatchPath
 GM: drawing... selftest1 [300 200]
 GM: Ran 1 GMs
 GM: ... over  2 configs ["8888", "565"]
diff --git a/gm/tests/outputs/compared-against-empty-dir/output-expected/writePath/565/selftest1.png b/gm/tests/outputs/compared-against-empty-dir/output-expected/writePath/565/selftest1.png
new file mode 100644
index 0000000..6fd4126
--- /dev/null
+++ b/gm/tests/outputs/compared-against-empty-dir/output-expected/writePath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-empty-dir/output-actual/writePath/565/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-empty-dir/output-expected/writePath/8888/selftest1.png b/gm/tests/outputs/compared-against-empty-dir/output-expected/writePath/8888/selftest1.png
new file mode 100644
index 0000000..8d82f51
--- /dev/null
+++ b/gm/tests/outputs/compared-against-empty-dir/output-expected/writePath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-empty-dir/output-actual/writePath/8888/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/command_line b/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/command_line
index ab8bac6..51e4582 100644
--- a/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/command_line
+++ b/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/command_line
@@ -1 +1 @@
-out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/images/identical-bytes --writeJsonSummaryPath gm/tests/outputs/compared-against-identical-bytes-images/output-actual/json-summary.txt
+out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/images/identical-bytes --writeJsonSummaryPath gm/tests/outputs/compared-against-identical-bytes-images/output-actual/json-summary.txt --writePath gm/tests/outputs/compared-against-identical-bytes-images/output-actual/writePath --mismatchPath gm/tests/outputs/compared-against-identical-bytes-images/output-actual/mismatchPath
diff --git a/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/mismatchPath/565/bogusfile b/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/mismatchPath/565/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/mismatchPath/565/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/mismatchPath/8888/bogusfile b/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/mismatchPath/8888/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/mismatchPath/8888/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/stdout b/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/stdout
index d63fca5..e844583 100644
--- a/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/stdout
+++ b/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/stdout
@@ -1,5 +1,7 @@
 GM: These configs will be run: 8888 565
 GM: reading from gm/tests/inputs/images/identical-bytes
+GM: writing to gm/tests/outputs/compared-against-identical-bytes-images/output-actual/writePath
+GM: writing mismatches to gm/tests/outputs/compared-against-identical-bytes-images/output-actual/mismatchPath
 GM: drawing... selftest1 [300 200]
 GM: Ran 1 GMs
 GM: ... over  2 configs ["8888", "565"]
diff --git a/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/writePath/565/selftest1.png b/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/writePath/565/selftest1.png
new file mode 100644
index 0000000..be0614f
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/writePath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-identical-bytes-images/output-actual/writePath/565/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/writePath/8888/selftest1.png b/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/writePath/8888/selftest1.png
new file mode 100644
index 0000000..6575039
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-bytes-images/output-expected/writePath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-identical-bytes-images/output-actual/writePath/8888/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/command_line b/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/command_line
index 8f34c11..3a29e12 100644
--- a/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/command_line
+++ b/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/command_line
@@ -1 +1 @@
-out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/json/identical-bytes.json --writeJsonSummaryPath gm/tests/outputs/compared-against-identical-bytes-json/output-actual/json-summary.txt
+out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/json/identical-bytes.json --writeJsonSummaryPath gm/tests/outputs/compared-against-identical-bytes-json/output-actual/json-summary.txt --writePath gm/tests/outputs/compared-against-identical-bytes-json/output-actual/writePath --mismatchPath gm/tests/outputs/compared-against-identical-bytes-json/output-actual/mismatchPath
diff --git a/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/mismatchPath/565/bogusfile b/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/mismatchPath/565/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/mismatchPath/565/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/mismatchPath/8888/bogusfile b/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/mismatchPath/8888/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/mismatchPath/8888/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/stdout b/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/stdout
index 0c2b49c..9ed95b5 100644
--- a/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/stdout
+++ b/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/stdout
@@ -1,5 +1,7 @@
 GM: These configs will be run: 8888 565
 GM: reading expectations from JSON summary file gm/tests/inputs/json/identical-bytes.json
+GM: writing to gm/tests/outputs/compared-against-identical-bytes-json/output-actual/writePath
+GM: writing mismatches to gm/tests/outputs/compared-against-identical-bytes-json/output-actual/mismatchPath
 GM: drawing... selftest1 [300 200]
 GM: Ran 1 GMs
 GM: ... over  2 configs ["8888", "565"]
diff --git a/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/writePath/565/selftest1.png b/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/writePath/565/selftest1.png
new file mode 100644
index 0000000..31853e3
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/writePath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-identical-bytes-json/output-actual/writePath/565/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/writePath/8888/selftest1.png b/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/writePath/8888/selftest1.png
new file mode 100644
index 0000000..ee80ce2
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-bytes-json/output-expected/writePath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-identical-bytes-json/output-actual/writePath/8888/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/command_line b/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/command_line
index 23f498e..b967776 100644
--- a/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/command_line
+++ b/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/command_line
@@ -1 +1 @@
-out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/images/identical-pixels --writeJsonSummaryPath gm/tests/outputs/compared-against-identical-pixels-images/output-actual/json-summary.txt
+out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/images/identical-pixels --writeJsonSummaryPath gm/tests/outputs/compared-against-identical-pixels-images/output-actual/json-summary.txt --writePath gm/tests/outputs/compared-against-identical-pixels-images/output-actual/writePath --mismatchPath gm/tests/outputs/compared-against-identical-pixels-images/output-actual/mismatchPath
diff --git a/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/mismatchPath/565/bogusfile b/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/mismatchPath/565/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/mismatchPath/565/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/mismatchPath/8888/bogusfile b/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/mismatchPath/8888/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/mismatchPath/8888/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/stdout b/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/stdout
index fd1703a..e61e9f3 100644
--- a/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/stdout
+++ b/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/stdout
@@ -1,5 +1,7 @@
 GM: These configs will be run: 8888 565
 GM: reading from gm/tests/inputs/images/identical-pixels
+GM: writing to gm/tests/outputs/compared-against-identical-pixels-images/output-actual/writePath
+GM: writing mismatches to gm/tests/outputs/compared-against-identical-pixels-images/output-actual/mismatchPath
 GM: drawing... selftest1 [300 200]
 GM: Ran 1 GMs
 GM: ... over  2 configs ["8888", "565"]
diff --git a/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/writePath/565/selftest1.png b/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/writePath/565/selftest1.png
new file mode 100644
index 0000000..8961f2b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/writePath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-identical-pixels-images/output-actual/writePath/565/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/writePath/8888/selftest1.png b/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/writePath/8888/selftest1.png
new file mode 100644
index 0000000..19b3ba3
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-pixels-images/output-expected/writePath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-identical-pixels-images/output-actual/writePath/8888/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/command_line b/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/command_line
index 9fe0158..71a9ac7 100644
--- a/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/command_line
+++ b/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/command_line
@@ -1 +1 @@
-out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/json/identical-pixels.json --writeJsonSummaryPath gm/tests/outputs/compared-against-identical-pixels-json/output-actual/json-summary.txt
+out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/json/identical-pixels.json --writeJsonSummaryPath gm/tests/outputs/compared-against-identical-pixels-json/output-actual/json-summary.txt --writePath gm/tests/outputs/compared-against-identical-pixels-json/output-actual/writePath --mismatchPath gm/tests/outputs/compared-against-identical-pixels-json/output-actual/mismatchPath
diff --git a/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/mismatchPath/565/bogusfile b/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/mismatchPath/565/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/mismatchPath/565/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/mismatchPath/8888/bogusfile b/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/mismatchPath/8888/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/mismatchPath/8888/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/stdout b/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/stdout
index b9c1e4a..562ccdc 100644
--- a/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/stdout
+++ b/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/stdout
@@ -1,5 +1,7 @@
 GM: These configs will be run: 8888 565
 GM: reading expectations from JSON summary file gm/tests/inputs/json/identical-pixels.json
+GM: writing to gm/tests/outputs/compared-against-identical-pixels-json/output-actual/writePath
+GM: writing mismatches to gm/tests/outputs/compared-against-identical-pixels-json/output-actual/mismatchPath
 GM: drawing... selftest1 [300 200]
 GM: Ran 1 GMs
 GM: ... over  2 configs ["8888", "565"]
diff --git a/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/writePath/565/selftest1.png b/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/writePath/565/selftest1.png
new file mode 100644
index 0000000..357c3f9
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/writePath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-identical-pixels-json/output-actual/writePath/565/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/writePath/8888/selftest1.png b/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/writePath/8888/selftest1.png
new file mode 100644
index 0000000..1da34ea
--- /dev/null
+++ b/gm/tests/outputs/compared-against-identical-pixels-json/output-expected/writePath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/compared-against-identical-pixels-json/output-actual/writePath/8888/selftest1.png]
diff --git a/gm/tests/outputs/compared-against-nonexistent-dir/output-expected/command_line b/gm/tests/outputs/compared-against-nonexistent-dir/output-expected/command_line
index 03ff199..1753a9f 100644
--- a/gm/tests/outputs/compared-against-nonexistent-dir/output-expected/command_line
+++ b/gm/tests/outputs/compared-against-nonexistent-dir/output-expected/command_line
@@ -1 +1 @@
-out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r ../path/to/nowhere --writeJsonSummaryPath gm/tests/outputs/compared-against-nonexistent-dir/output-actual/json-summary.txt
+out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 -r ../path/to/nowhere --writeJsonSummaryPath gm/tests/outputs/compared-against-nonexistent-dir/output-actual/json-summary.txt --writePath gm/tests/outputs/compared-against-nonexistent-dir/output-actual/writePath --mismatchPath gm/tests/outputs/compared-against-nonexistent-dir/output-actual/mismatchPath
diff --git a/gm/tests/outputs/ignore-expectations-mismatch/output-expected/command_line b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/command_line
index f8ffbc8..c9a4ed0 100644
--- a/gm/tests/outputs/ignore-expectations-mismatch/output-expected/command_line
+++ b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/command_line
@@ -1 +1 @@
-out/Debug/gm --ignoreErrorTypes ExpectationsMismatch NoGpuContext --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/json/different-pixels.json --writeJsonSummaryPath gm/tests/outputs/ignore-expectations-mismatch/output-actual/json-summary.txt
+out/Debug/gm --ignoreErrorTypes ExpectationsMismatch NoGpuContext --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/json/different-pixels.json --writeJsonSummaryPath gm/tests/outputs/ignore-expectations-mismatch/output-actual/json-summary.txt --writePath gm/tests/outputs/ignore-expectations-mismatch/output-actual/writePath --mismatchPath gm/tests/outputs/ignore-expectations-mismatch/output-actual/mismatchPath
diff --git a/gm/tests/outputs/ignore-expectations-mismatch/output-expected/mismatchPath/565/bogusfile b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/mismatchPath/565/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/mismatchPath/565/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/ignore-expectations-mismatch/output-expected/mismatchPath/565/selftest1.png b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/mismatchPath/565/selftest1.png
new file mode 100644
index 0000000..95247f8
--- /dev/null
+++ b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/mismatchPath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/ignore-expectations-mismatch/output-actual/mismatchPath/565/selftest1.png]
diff --git a/gm/tests/outputs/ignore-expectations-mismatch/output-expected/mismatchPath/8888/bogusfile b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/mismatchPath/8888/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/mismatchPath/8888/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/ignore-expectations-mismatch/output-expected/mismatchPath/8888/selftest1.png b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/mismatchPath/8888/selftest1.png
new file mode 100644
index 0000000..73c7841
--- /dev/null
+++ b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/mismatchPath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/ignore-expectations-mismatch/output-actual/mismatchPath/8888/selftest1.png]
diff --git a/gm/tests/outputs/ignore-expectations-mismatch/output-expected/stdout b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/stdout
index 6ccc85d..635f9af 100644
--- a/gm/tests/outputs/ignore-expectations-mismatch/output-expected/stdout
+++ b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/stdout
@@ -1,5 +1,7 @@
 GM: These configs will be run: 8888 565
 GM: reading expectations from JSON summary file gm/tests/inputs/json/different-pixels.json
+GM: writing to gm/tests/outputs/ignore-expectations-mismatch/output-actual/writePath
+GM: writing mismatches to gm/tests/outputs/ignore-expectations-mismatch/output-actual/mismatchPath
 GM: drawing... selftest1 [300 200]
 GM: Ran 1 GMs
 GM: ... over  2 configs ["8888", "565"]
diff --git a/gm/tests/outputs/ignore-expectations-mismatch/output-expected/writePath/565/selftest1.png b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/writePath/565/selftest1.png
new file mode 100644
index 0000000..5b86add
--- /dev/null
+++ b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/writePath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/ignore-expectations-mismatch/output-actual/writePath/565/selftest1.png]
diff --git a/gm/tests/outputs/ignore-expectations-mismatch/output-expected/writePath/8888/selftest1.png b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/writePath/8888/selftest1.png
new file mode 100644
index 0000000..b33ea83
--- /dev/null
+++ b/gm/tests/outputs/ignore-expectations-mismatch/output-expected/writePath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/ignore-expectations-mismatch/output-actual/writePath/8888/selftest1.png]
diff --git a/gm/tests/outputs/intentionally-skipped-tests/output-expected/command_line b/gm/tests/outputs/intentionally-skipped-tests/output-expected/command_line
index 361cb52..29ff44d 100644
--- a/gm/tests/outputs/intentionally-skipped-tests/output-expected/command_line
+++ b/gm/tests/outputs/intentionally-skipped-tests/output-expected/command_line
@@ -1 +1 @@
-out/Debug/gm --verbose --hierarchy --match selftest1 selftest2 --config 8888 565 --writeJsonSummaryPath gm/tests/outputs/intentionally-skipped-tests/output-actual/json-summary.txt
+out/Debug/gm --verbose --hierarchy --match selftest1 selftest2 --config 8888 565 --writeJsonSummaryPath gm/tests/outputs/intentionally-skipped-tests/output-actual/json-summary.txt --writePath gm/tests/outputs/intentionally-skipped-tests/output-actual/writePath --mismatchPath gm/tests/outputs/intentionally-skipped-tests/output-actual/mismatchPath
diff --git a/gm/tests/outputs/intentionally-skipped-tests/output-expected/mismatchPath/565/bogusfile b/gm/tests/outputs/intentionally-skipped-tests/output-expected/mismatchPath/565/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/intentionally-skipped-tests/output-expected/mismatchPath/565/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/intentionally-skipped-tests/output-expected/mismatchPath/8888/bogusfile b/gm/tests/outputs/intentionally-skipped-tests/output-expected/mismatchPath/8888/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/intentionally-skipped-tests/output-expected/mismatchPath/8888/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/intentionally-skipped-tests/output-expected/stdout b/gm/tests/outputs/intentionally-skipped-tests/output-expected/stdout
index f7eec19..b94f24c 100644
--- a/gm/tests/outputs/intentionally-skipped-tests/output-expected/stdout
+++ b/gm/tests/outputs/intentionally-skipped-tests/output-expected/stdout
@@ -1,4 +1,6 @@
 GM: These configs will be run: 8888 565
+GM: writing to gm/tests/outputs/intentionally-skipped-tests/output-actual/writePath
+GM: writing mismatches to gm/tests/outputs/intentionally-skipped-tests/output-actual/mismatchPath
 GM: drawing... selftest2 [300 200]
 GM: drawing... selftest1 [300 200]
 GM: Ran 2 GMs
diff --git a/gm/tests/outputs/intentionally-skipped-tests/output-expected/writePath/565/selftest1.png b/gm/tests/outputs/intentionally-skipped-tests/output-expected/writePath/565/selftest1.png
new file mode 100644
index 0000000..fd1af59
--- /dev/null
+++ b/gm/tests/outputs/intentionally-skipped-tests/output-expected/writePath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/intentionally-skipped-tests/output-actual/writePath/565/selftest1.png]
diff --git a/gm/tests/outputs/intentionally-skipped-tests/output-expected/writePath/565/selftest2.png b/gm/tests/outputs/intentionally-skipped-tests/output-expected/writePath/565/selftest2.png
new file mode 100644
index 0000000..44bbef7
--- /dev/null
+++ b/gm/tests/outputs/intentionally-skipped-tests/output-expected/writePath/565/selftest2.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/intentionally-skipped-tests/output-actual/writePath/565/selftest2.png]
diff --git a/gm/tests/outputs/intentionally-skipped-tests/output-expected/writePath/8888/selftest1.png b/gm/tests/outputs/intentionally-skipped-tests/output-expected/writePath/8888/selftest1.png
new file mode 100644
index 0000000..a322ded
--- /dev/null
+++ b/gm/tests/outputs/intentionally-skipped-tests/output-expected/writePath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/intentionally-skipped-tests/output-actual/writePath/8888/selftest1.png]
diff --git a/gm/tests/outputs/intentionally-skipped-tests/output-expected/writePath/8888/selftest2.png b/gm/tests/outputs/intentionally-skipped-tests/output-expected/writePath/8888/selftest2.png
new file mode 100644
index 0000000..c56ee69
--- /dev/null
+++ b/gm/tests/outputs/intentionally-skipped-tests/output-expected/writePath/8888/selftest2.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/intentionally-skipped-tests/output-actual/writePath/8888/selftest2.png]
diff --git a/gm/tests/outputs/no-readpath/output-expected/command_line b/gm/tests/outputs/no-readpath/output-expected/command_line
index 3192ddb..bb3679c 100644
--- a/gm/tests/outputs/no-readpath/output-expected/command_line
+++ b/gm/tests/outputs/no-readpath/output-expected/command_line
@@ -1 +1 @@
-out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 --writeJsonSummaryPath gm/tests/outputs/no-readpath/output-actual/json-summary.txt
+out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 --writeJsonSummaryPath gm/tests/outputs/no-readpath/output-actual/json-summary.txt --writePath gm/tests/outputs/no-readpath/output-actual/writePath --mismatchPath gm/tests/outputs/no-readpath/output-actual/mismatchPath
diff --git a/gm/tests/outputs/no-readpath/output-expected/mismatchPath/565/bogusfile b/gm/tests/outputs/no-readpath/output-expected/mismatchPath/565/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/no-readpath/output-expected/mismatchPath/565/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/no-readpath/output-expected/mismatchPath/8888/bogusfile b/gm/tests/outputs/no-readpath/output-expected/mismatchPath/8888/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/no-readpath/output-expected/mismatchPath/8888/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/no-readpath/output-expected/stdout b/gm/tests/outputs/no-readpath/output-expected/stdout
index 7ce257b..43f4ca3 100644
--- a/gm/tests/outputs/no-readpath/output-expected/stdout
+++ b/gm/tests/outputs/no-readpath/output-expected/stdout
@@ -1,4 +1,6 @@
 GM: These configs will be run: 8888 565
+GM: writing to gm/tests/outputs/no-readpath/output-actual/writePath
+GM: writing mismatches to gm/tests/outputs/no-readpath/output-actual/mismatchPath
 GM: drawing... selftest1 [300 200]
 GM: Ran 1 GMs
 GM: ... over  2 configs ["8888", "565"]
diff --git a/gm/tests/outputs/no-readpath/output-expected/writePath/565/selftest1.png b/gm/tests/outputs/no-readpath/output-expected/writePath/565/selftest1.png
new file mode 100644
index 0000000..2943f0a
--- /dev/null
+++ b/gm/tests/outputs/no-readpath/output-expected/writePath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/no-readpath/output-actual/writePath/565/selftest1.png]
diff --git a/gm/tests/outputs/no-readpath/output-expected/writePath/8888/selftest1.png b/gm/tests/outputs/no-readpath/output-expected/writePath/8888/selftest1.png
new file mode 100644
index 0000000..50a0c24
--- /dev/null
+++ b/gm/tests/outputs/no-readpath/output-expected/writePath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/no-readpath/output-actual/writePath/8888/selftest1.png]
diff --git a/gm/tests/outputs/nonverbose/output-expected/command_line b/gm/tests/outputs/nonverbose/output-expected/command_line
index 7c71a72..911455f 100644
--- a/gm/tests/outputs/nonverbose/output-expected/command_line
+++ b/gm/tests/outputs/nonverbose/output-expected/command_line
@@ -1 +1 @@
-out/Debug/gm --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/images/empty-dir --writeJsonSummaryPath gm/tests/outputs/nonverbose/output-actual/json-summary.txt
+out/Debug/gm --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/images/empty-dir --writeJsonSummaryPath gm/tests/outputs/nonverbose/output-actual/json-summary.txt --writePath gm/tests/outputs/nonverbose/output-actual/writePath --mismatchPath gm/tests/outputs/nonverbose/output-actual/mismatchPath
diff --git a/gm/tests/outputs/nonverbose/output-expected/mismatchPath/565/bogusfile b/gm/tests/outputs/nonverbose/output-expected/mismatchPath/565/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/nonverbose/output-expected/mismatchPath/565/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/nonverbose/output-expected/mismatchPath/8888/bogusfile b/gm/tests/outputs/nonverbose/output-expected/mismatchPath/8888/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/nonverbose/output-expected/mismatchPath/8888/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/nonverbose/output-expected/writePath/565/selftest1.png b/gm/tests/outputs/nonverbose/output-expected/writePath/565/selftest1.png
new file mode 100644
index 0000000..6b9d422
--- /dev/null
+++ b/gm/tests/outputs/nonverbose/output-expected/writePath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/nonverbose/output-actual/writePath/565/selftest1.png]
diff --git a/gm/tests/outputs/nonverbose/output-expected/writePath/8888/selftest1.png b/gm/tests/outputs/nonverbose/output-expected/writePath/8888/selftest1.png
new file mode 100644
index 0000000..4f04a60
--- /dev/null
+++ b/gm/tests/outputs/nonverbose/output-expected/writePath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/nonverbose/output-actual/writePath/8888/selftest1.png]
diff --git a/gm/tests/outputs/pipe-playback-failure/output-expected/command_line b/gm/tests/outputs/pipe-playback-failure/output-expected/command_line
index 28c5a67..ffcf72d 100644
--- a/gm/tests/outputs/pipe-playback-failure/output-expected/command_line
+++ b/gm/tests/outputs/pipe-playback-failure/output-expected/command_line
@@ -1 +1 @@
-out/Debug/gm --simulatePipePlaybackFailure --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/json/identical-pixels.json --writeJsonSummaryPath gm/tests/outputs/pipe-playback-failure/output-actual/json-summary.txt
+out/Debug/gm --simulatePipePlaybackFailure --verbose --hierarchy --match selftest1 --config 8888 565 -r gm/tests/inputs/json/identical-pixels.json --writeJsonSummaryPath gm/tests/outputs/pipe-playback-failure/output-actual/json-summary.txt --writePath gm/tests/outputs/pipe-playback-failure/output-actual/writePath --mismatchPath gm/tests/outputs/pipe-playback-failure/output-actual/mismatchPath
diff --git a/gm/tests/outputs/pipe-playback-failure/output-expected/mismatchPath/565/bogusfile b/gm/tests/outputs/pipe-playback-failure/output-expected/mismatchPath/565/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/pipe-playback-failure/output-expected/mismatchPath/565/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/pipe-playback-failure/output-expected/mismatchPath/8888/bogusfile b/gm/tests/outputs/pipe-playback-failure/output-expected/mismatchPath/8888/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/pipe-playback-failure/output-expected/mismatchPath/8888/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/pipe-playback-failure/output-expected/stdout b/gm/tests/outputs/pipe-playback-failure/output-expected/stdout
index 811f5a7..e15af88 100644
--- a/gm/tests/outputs/pipe-playback-failure/output-expected/stdout
+++ b/gm/tests/outputs/pipe-playback-failure/output-expected/stdout
@@ -1,5 +1,7 @@
 GM: These configs will be run: 8888 565
 GM: reading expectations from JSON summary file gm/tests/inputs/json/identical-pixels.json
+GM: writing to gm/tests/outputs/pipe-playback-failure/output-actual/writePath
+GM: writing mismatches to gm/tests/outputs/pipe-playback-failure/output-actual/mismatchPath
 GM: drawing... selftest1 [300 200]
 GM: Ran 1 GMs
 GM: ... over  2 configs ["8888", "565"]
diff --git a/gm/tests/outputs/pipe-playback-failure/output-expected/writePath/565/selftest1.png b/gm/tests/outputs/pipe-playback-failure/output-expected/writePath/565/selftest1.png
new file mode 100644
index 0000000..5fec296
--- /dev/null
+++ b/gm/tests/outputs/pipe-playback-failure/output-expected/writePath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/pipe-playback-failure/output-actual/writePath/565/selftest1.png]
diff --git a/gm/tests/outputs/pipe-playback-failure/output-expected/writePath/8888/selftest1.png b/gm/tests/outputs/pipe-playback-failure/output-expected/writePath/8888/selftest1.png
new file mode 100644
index 0000000..975f68f
--- /dev/null
+++ b/gm/tests/outputs/pipe-playback-failure/output-expected/writePath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/pipe-playback-failure/output-actual/writePath/8888/selftest1.png]
diff --git a/gm/tests/run.sh b/gm/tests/run.sh
index b3f23ce..e9cc19d 100755
--- a/gm/tests/run.sh
+++ b/gm/tests/run.sh
@@ -21,12 +21,6 @@
 # TODO(epoger): make it look in Release and/or Debug
 GM_BINARY=out/Debug/gm
 
-# If WRITE_IMAGE_FILES is nonzero, then the self-test will pass --writePath
-# and --mismatchPath arguments to GM.  Currently, for various reasons, we
-# cannot run these arguments on the production buildbots, so this should
-# only be set to nonzero for local testing.
-WRITE_IMAGE_FILES=0
-
 OUTPUT_ACTUAL_SUBDIR=output-actual
 OUTPUT_EXPECTED_SUBDIR=output-expected
 CONFIGS="--config 8888 565"
@@ -69,10 +63,7 @@
   rm -rf $ACTUAL_OUTPUT_DIR
   mkdir -p $ACTUAL_OUTPUT_DIR
 
-  COMMAND="$GM_BINARY $GM_ARGS --writeJsonSummaryPath $JSON_SUMMARY_FILE"
-  if [ $WRITE_IMAGE_FILES != 0 ]; then
-    COMMAND="$COMMAND --writePath $ACTUAL_OUTPUT_DIR/writePath --mismatchPath $ACTUAL_OUTPUT_DIR/mismatchPath"
-  fi
+  COMMAND="$GM_BINARY $GM_ARGS --writeJsonSummaryPath $JSON_SUMMARY_FILE --writePath $ACTUAL_OUTPUT_DIR/writePath --mismatchPath $ACTUAL_OUTPUT_DIR/mismatchPath"
 
   echo "$COMMAND" >$ACTUAL_OUTPUT_DIR/command_line
   $COMMAND >$ACTUAL_OUTPUT_DIR/stdout 2>$ACTUAL_OUTPUT_DIR/stderr
@@ -88,16 +79,16 @@
   grep ^GM: $ACTUAL_OUTPUT_DIR/stderr >$ACTUAL_OUTPUT_DIR/stderr-tmp
   mv $ACTUAL_OUTPUT_DIR/stderr-tmp $ACTUAL_OUTPUT_DIR/stderr
 
-  if [ $WRITE_IMAGE_FILES != 0 ]; then
-    for IMAGEFILE in $(ls $ACTUAL_OUTPUT_DIR/*/*/*.png); do
-      SUM=$(sum $IMAGEFILE)
-      echo "Replaced image bytes with a checksum, because of https://code.google.com/p/chromium/issues/detail?id=169600 ('gcl/upload.py fail to upload binary files to rietveld')" >$IMAGEFILE
-      echo $SUM >> $IMAGEFILE
-    done
-    for MISMATCHDIR in $(ls -d $ACTUAL_OUTPUT_DIR/mismatchPath/*); do
-      echo "Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories." >$MISMATCHDIR/bogusfile
-    done
-  fi
+  # Replace image file contents with just the filename, for two reasons:
+  # 1. Image file encoding may vary by platform
+  # 2. https://code.google.com/p/chromium/issues/detail?id=169600
+  #    ('gcl/upload.py fail to upload binary files to rietveld')
+  for IMAGEFILE in $(ls $ACTUAL_OUTPUT_DIR/*/*/*.png); do
+    echo "[contents of $IMAGEFILE]" >$IMAGEFILE
+  done
+  for MISMATCHDIR in $(ls -d $ACTUAL_OUTPUT_DIR/mismatchPath/*); do
+    echo "Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories." >$MISMATCHDIR/bogusfile
+  done
 
   compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR
 }