test-only change: update run.sh and rearrange dirs to ease addition of more tests
authorepoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 17 May 2012 17:12:38 +0000 (17:12 +0000)
committerepoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 17 May 2012 17:12:38 +0000 (17:12 +0000)
Review URL: https://codereview.appspot.com/6220044

git-svn-id: http://skia.googlecode.com/svn/trunk@3995 2bbb7eff-a529-9590-31e7-b0007b416f81

tools/tests/run.sh
tools/tests/skdiff/output-expected/index.html [deleted file]
tools/tests/skdiff/test1/output-expected/index.html [new file with mode: 0644]
tools/tests/skdiff/test1/output-expected/slightly-different-pixels-same-size-diff.png [moved from tools/tests/skdiff/output-expected/slightly-different-pixels-same-size-diff.png with 100% similarity]
tools/tests/skdiff/test1/output-expected/slightly-different-pixels-same-size-white.png [moved from tools/tests/skdiff/output-expected/slightly-different-pixels-same-size-white.png with 100% similarity]
tools/tests/skdiff/test1/output-expected/stdout [moved from tools/tests/skdiff/output-expected/stdout with 90% similarity]
tools/tests/skdiff/test1/output-expected/very-different-pixels-same-size-diff.png [moved from tools/tests/skdiff/output-expected/very-different-pixels-same-size-diff.png with 100% similarity]
tools/tests/skdiff/test1/output-expected/very-different-pixels-same-size-white.png [moved from tools/tests/skdiff/output-expected/very-different-pixels-same-size-white.png with 100% similarity]

index 6c2f549..c3c5bbc 100755 (executable)
@@ -7,6 +7,11 @@
 # TODO: make it look in Release and/or Debug
 SKDIFF_BINARY=out/Debug/skdiff
 
+# Compare contents of all files within directories $1 and $2,
+# EXCEPT for any dotfiles.
+# If there are any differences, a description is written to stdout and
+# we exit with a nonzero return value.
+# Otherwise, we write nothing to stdout and return.
 function compare_directories {
   diff --exclude=.* $1 $2
   if [ $? != 0 ]; then
@@ -15,14 +20,20 @@ function compare_directories {
   fi
 }
 
-# Test skdiff...
-#
-SKDIFF_TESTDIR=tools/tests/skdiff
-SKDIFF_OUTPUT_DIR=$SKDIFF_TESTDIR/output-actual
-rm -rf $SKDIFF_OUTPUT_DIR
-mkdir -p $SKDIFF_OUTPUT_DIR
-$SKDIFF_BINARY $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir \
-  $SKDIFF_OUTPUT_DIR &>$SKDIFF_OUTPUT_DIR/stdout
-compare_directories $SKDIFF_TESTDIR/output-expected $SKDIFF_OUTPUT_DIR
+# Run skdiff with arguments in $1 (plus implicit final argument causing skdiff
+# to write its output, if any, to directory $2/output-actual).
+# Then compare its results against those in $2/output-expected.
+function skdiff_test {
+  SKDIFF_ARGS="$1"
+  ACTUAL_OUTPUT_DIR="$2/output-actual"
+  EXPECTED_OUTPUT_DIR="$2/output-expected"
+
+  rm -rf $ACTUAL_OUTPUT_DIR
+  mkdir -p $ACTUAL_OUTPUT_DIR
+  $SKDIFF_BINARY $SKDIFF_ARGS $ACTUAL_OUTPUT_DIR &>$ACTUAL_OUTPUT_DIR/stdout
+  compare_directories $EXPECTED_OUTPUT_DIR $ACTUAL_OUTPUT_DIR
+}
 
+SKDIFF_TESTDIR=tools/tests/skdiff
+skdiff_test "$SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir" "$SKDIFF_TESTDIR/test1"
 echo "All tests passed."
diff --git a/tools/tests/skdiff/output-expected/index.html b/tools/tests/skdiff/output-expected/index.html
deleted file mode 100644 (file)
index be6ea77..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-<html>
-<body>
-<table>
-<tr><th>4 of 12 images matched exactly.<br></th>
-<th>every different pixel shown in white</th>
-<th>color difference at each pixel</th>
-<th>tools/tests/skdiff/baseDir/</th>
-<th>tools/tests/skdiff/comparisonDir/</th>
-</tr>
-<tr>
-<td>slightly-different-sizes.png<br>Image sizes differ</td><td align=center>[image size mismatch, so no diff to display]</td><td align=center>[image size mismatch, so no diff to display]</td><td><a href="../../../../tools/tests/skdiff/baseDir/slightly-different-sizes.png"><img src="../../../../tools/tests/skdiff/baseDir/slightly-different-sizes.png" height="240px"></a></td><td><a href="../../../../tools/tests/skdiff/comparisonDir/slightly-different-sizes.png"><img src="../../../../tools/tests/skdiff/comparisonDir/slightly-different-sizes.png" height="240px"></a></td></tr>
-<tr>
-<td>very-different-sizes.png<br>Image sizes differ</td><td align=center>[image size mismatch, so no diff to display]</td><td align=center>[image size mismatch, so no diff to display]</td><td><a href="../../../../tools/tests/skdiff/baseDir/very-different-sizes.png"><img src="../../../../tools/tests/skdiff/baseDir/very-different-sizes.png" height="240px"></a></td><td><a href="../../../../tools/tests/skdiff/comparisonDir/very-different-sizes.png"><img src="../../../../tools/tests/skdiff/comparisonDir/very-different-sizes.png" height="240px"></a></td></tr>
-<tr>
-<td>very-different-pixels-same-size.png<br>     97.9926% of pixels differ
-  (     42.8911% weighted)<br>Average color mismatch 89<br>Max color mismatch 239</td><td><a href="very-different-pixels-same-size-white.png"><img src="very-different-pixels-same-size-white.png" height="240px"></a></td><td><a href="very-different-pixels-same-size-diff.png"><img src="very-different-pixels-same-size-diff.png" height="240px"></a></td><td><a href="../../../../tools/tests/skdiff/baseDir/very-different-pixels-same-size.png"><img src="../../../../tools/tests/skdiff/baseDir/very-different-pixels-same-size.png" height="240px"></a></td><td><a href="../../../../tools/tests/skdiff/comparisonDir/very-different-pixels-same-size.png"><img src="../../../../tools/tests/skdiff/comparisonDir/very-different-pixels-same-size.png" height="240px"></a></td></tr>
-<tr>
-<td>slightly-different-pixels-same-size.png<br>      0.6630% of pixels differ
-  (      0.1904% weighted)<br>(2164 pixels)<br>Average color mismatch 0<br>Max color mismatch 213</td><td><a href="slightly-different-pixels-same-size-white.png"><img src="slightly-different-pixels-same-size-white.png" height="240px"></a></td><td><a href="slightly-different-pixels-same-size-diff.png"><img src="slightly-different-pixels-same-size-diff.png" height="240px"></a></td><td><a href="../../../../tools/tests/skdiff/baseDir/slightly-different-pixels-same-size.png"><img src="../../../../tools/tests/skdiff/baseDir/slightly-different-pixels-same-size.png" height="240px"></a></td><td><a href="../../../../tools/tests/skdiff/comparisonDir/slightly-different-pixels-same-size.png"><img src="../../../../tools/tests/skdiff/comparisonDir/slightly-different-pixels-same-size.png" height="240px"></a></td></tr>
-<tr>
-<td>missing-from-baseDir.png<br></td><td>N/A</td><td>N/A</td><td>N/A</td><td><a href="../../../../tools/tests/skdiff/comparisonDir/missing-from-baseDir.png"><img src="../../../../tools/tests/skdiff/comparisonDir/missing-from-baseDir.png" height="240px"></a></td></tr>
-<tr>
-<td>missing-from-baseDir.xyz<br></td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td></tr>
-<tr>
-<td>missing-from-comparisonDir.png<br></td><td>N/A</td><td>N/A</td><td><a href="../../../../tools/tests/skdiff/baseDir/missing-from-comparisonDir.png"><img src="../../../../tools/tests/skdiff/baseDir/missing-from-comparisonDir.png" height="240px"></a></td><td>N/A</td></tr>
-<tr>
-<td>missing-from-comparisonDir.xyz<br></td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td></tr>
-</table>
-</body>
-</html>
diff --git a/tools/tests/skdiff/test1/output-expected/index.html b/tools/tests/skdiff/test1/output-expected/index.html
new file mode 100644 (file)
index 0000000..62ab699
--- /dev/null
@@ -0,0 +1,30 @@
+<html>
+<body>
+<table>
+<tr><th>4 of 12 images matched exactly.<br></th>
+<th>every different pixel shown in white</th>
+<th>color difference at each pixel</th>
+<th>tools/tests/skdiff/baseDir/</th>
+<th>tools/tests/skdiff/comparisonDir/</th>
+</tr>
+<tr>
+<td>slightly-different-sizes.png<br>Image sizes differ</td><td align=center>[image size mismatch, so no diff to display]</td><td align=center>[image size mismatch, so no diff to display]</td><td><a href="../../../../../tools/tests/skdiff/baseDir/slightly-different-sizes.png"><img src="../../../../../tools/tests/skdiff/baseDir/slightly-different-sizes.png" height="240px"></a></td><td><a href="../../../../../tools/tests/skdiff/comparisonDir/slightly-different-sizes.png"><img src="../../../../../tools/tests/skdiff/comparisonDir/slightly-different-sizes.png" height="240px"></a></td></tr>
+<tr>
+<td>very-different-sizes.png<br>Image sizes differ</td><td align=center>[image size mismatch, so no diff to display]</td><td align=center>[image size mismatch, so no diff to display]</td><td><a href="../../../../../tools/tests/skdiff/baseDir/very-different-sizes.png"><img src="../../../../../tools/tests/skdiff/baseDir/very-different-sizes.png" height="240px"></a></td><td><a href="../../../../../tools/tests/skdiff/comparisonDir/very-different-sizes.png"><img src="../../../../../tools/tests/skdiff/comparisonDir/very-different-sizes.png" height="240px"></a></td></tr>
+<tr>
+<td>very-different-pixels-same-size.png<br>     97.9926% of pixels differ
+  (     42.8911% weighted)<br>Average color mismatch 89<br>Max color mismatch 239</td><td><a href="very-different-pixels-same-size-white.png"><img src="very-different-pixels-same-size-white.png" height="240px"></a></td><td><a href="very-different-pixels-same-size-diff.png"><img src="very-different-pixels-same-size-diff.png" height="240px"></a></td><td><a href="../../../../../tools/tests/skdiff/baseDir/very-different-pixels-same-size.png"><img src="../../../../../tools/tests/skdiff/baseDir/very-different-pixels-same-size.png" height="240px"></a></td><td><a href="../../../../../tools/tests/skdiff/comparisonDir/very-different-pixels-same-size.png"><img src="../../../../../tools/tests/skdiff/comparisonDir/very-different-pixels-same-size.png" height="240px"></a></td></tr>
+<tr>
+<td>slightly-different-pixels-same-size.png<br>      0.6630% of pixels differ
+  (      0.1904% weighted)<br>(2164 pixels)<br>Average color mismatch 0<br>Max color mismatch 213</td><td><a href="slightly-different-pixels-same-size-white.png"><img src="slightly-different-pixels-same-size-white.png" height="240px"></a></td><td><a href="slightly-different-pixels-same-size-diff.png"><img src="slightly-different-pixels-same-size-diff.png" height="240px"></a></td><td><a href="../../../../../tools/tests/skdiff/baseDir/slightly-different-pixels-same-size.png"><img src="../../../../../tools/tests/skdiff/baseDir/slightly-different-pixels-same-size.png" height="240px"></a></td><td><a href="../../../../../tools/tests/skdiff/comparisonDir/slightly-different-pixels-same-size.png"><img src="../../../../../tools/tests/skdiff/comparisonDir/slightly-different-pixels-same-size.png" height="240px"></a></td></tr>
+<tr>
+<td>missing-from-baseDir.png<br></td><td>N/A</td><td>N/A</td><td>N/A</td><td><a href="../../../../../tools/tests/skdiff/comparisonDir/missing-from-baseDir.png"><img src="../../../../../tools/tests/skdiff/comparisonDir/missing-from-baseDir.png" height="240px"></a></td></tr>
+<tr>
+<td>missing-from-baseDir.xyz<br></td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td></tr>
+<tr>
+<td>missing-from-comparisonDir.png<br></td><td>N/A</td><td>N/A</td><td><a href="../../../../../tools/tests/skdiff/baseDir/missing-from-comparisonDir.png"><img src="../../../../../tools/tests/skdiff/baseDir/missing-from-comparisonDir.png" height="240px"></a></td><td>N/A</td></tr>
+<tr>
+<td>missing-from-comparisonDir.xyz<br></td><td>N/A</td><td>N/A</td><td>N/A</td><td>N/A</td></tr>
+</table>
+</body>
+</html>
similarity index 90%
rename from tools/tests/skdiff/output-expected/stdout
rename to tools/tests/skdiff/test1/output-expected/stdout
index b0bd641..4baf585 100644 (file)
@@ -4,7 +4,7 @@ ERROR: no codec found for <tools/tests/skdiff/comparisonDir/missing-from-baseDir
 ERROR: no codec found for <tools/tests/skdiff/baseDir/missing-from-comparisonDir.xyz>
 baseDir is [tools/tests/skdiff/baseDir/]
 comparisonDir is [tools/tests/skdiff/comparisonDir/]
-writing diffs to outputDir is [tools/tests/skdiff/output-actual/]
+writing diffs to outputDir is [tools/tests/skdiff/test1/output-actual/]
 Missing in baseDir:
        missing-from-baseDir.png
        missing-from-baseDir.xyz