# 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
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."
+++ /dev/null
-<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>
--- /dev/null
+<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>
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