Treat empty directory properly in skimage.

Instead of treating an empty directory as a file that failed to
decode, treat it as an empty directory.

Add self tests to check for this.

Builds upon from https://codereview.chromium.org/16866010,
which was reverted.

R=epoger@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@9730 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/tests/skimage_self_test.py b/tools/tests/skimage_self_test.py
index cb66fe1..24164d4 100755
--- a/tools/tests/skimage_self_test.py
+++ b/tools/tests/skimage_self_test.py
@@ -9,6 +9,7 @@
 import os
 import subprocess
 import sys
+import tempfile
 
 class BinaryNotFoundException(Exception):
     def __str__ (self):
@@ -70,6 +71,26 @@
     # TODO(scroggo): Add a test that compares expectations and image files that
     # are known to NOT match, and make sure it returns an error.
 
+    # Generate an expectations file from an empty directory.
+    empty_dir = tempfile.mkdtemp()
+    expectations_path = os.path.join(file_dir, "skimage", "output-actual",
+                                     "empty-dir", "expectations.json")
+    subprocess.check_call([skimage_binary, "--readPath", empty_dir,
+                           "--createExpectationsPath", expectations_path])
+    golden_expectations = os.path.join(file_dir, "skimage", "output-expected",
+                                       "empty-dir", "expectations.json")
+    DieIfFilesMismatch(expected=golden_expectations, actual=expectations_path)
+    os.rmdir(empty_dir)
+
+    # Generate an expectations file from a nonexistent directory.
+    expectations_path = os.path.join(file_dir, "skimage", "output-actual",
+                                     "nonexistent-dir", "expectations.json")
+    subprocess.check_call([skimage_binary, "--readPath", "/nonexistent/dir",
+                           "--createExpectationsPath", expectations_path])
+    golden_expectations = os.path.join(file_dir, "skimage", "output-expected",
+                                       "nonexistent-dir", "expectations.json")
+    DieIfFilesMismatch(expected=golden_expectations, actual=expectations_path)
+
     # Done with all tests.
     print "Self tests succeeded!"