diff options
author | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-06-17 19:34:58 +0000 |
---|---|---|
committer | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-06-17 19:34:58 +0000 |
commit | e0433f1ad3c9b163bc21a561903f2eef8277111d (patch) | |
tree | 6eee3fb2ae306a98aa6c668bd2d6250ab8cecb16 /tools | |
parent | bb5228888253b21ce81f0a89b605cdd7f88c0efc (diff) |
skimage: if --readPath points at an empty dir, create an empty expectations file
TBR=scroggo
Review URL: https://codereview.chromium.org/17294006
git-svn-id: http://skia.googlecode.com/svn/trunk@9642 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools')
-rw-r--r-- | tools/skimage_main.cpp | 3 | ||||
-rw-r--r-- | tools/tests/skimage/output-expected/empty-dir/expectations.json | 9 | ||||
-rw-r--r-- | tools/tests/skimage/output-expected/nonexistent-dir/expectations.json | 9 | ||||
-rwxr-xr-x | tools/tests/skimage_self_test.py | 21 |
4 files changed, 41 insertions, 1 deletions
diff --git a/tools/skimage_main.cpp b/tools/skimage_main.cpp index 107d3bfdb8..b115392abb 100644 --- a/tools/skimage_main.cpp +++ b/tools/skimage_main.cpp @@ -515,7 +515,8 @@ int tool_main(int argc, char** argv) { decodeFileAndWrite(fullname.c_str(), outDirPtr); } while (iter.next(&filename)); } else { - decodeFileAndWrite(FLAGS_readPath[i], outDirPtr); + // FLAGS_readPath[i] is an empty or nonexistent directory, + // so do nothing. } } diff --git a/tools/tests/skimage/output-expected/empty-dir/expectations.json b/tools/tests/skimage/output-expected/empty-dir/expectations.json new file mode 100644 index 0000000000..1ce8e2774c --- /dev/null +++ b/tools/tests/skimage/output-expected/empty-dir/expectations.json @@ -0,0 +1,9 @@ +{ + "actual-results" : { + "failed" : null, + "failure-ignored" : null, + "no-comparison" : null, + "succeeded" : null + }, + "expected-results" : null +} diff --git a/tools/tests/skimage/output-expected/nonexistent-dir/expectations.json b/tools/tests/skimage/output-expected/nonexistent-dir/expectations.json new file mode 100644 index 0000000000..1ce8e2774c --- /dev/null +++ b/tools/tests/skimage/output-expected/nonexistent-dir/expectations.json @@ -0,0 +1,9 @@ +{ + "actual-results" : { + "failed" : null, + "failure-ignored" : null, + "no-comparison" : null, + "succeeded" : null + }, + "expected-results" : null +} diff --git a/tools/tests/skimage_self_test.py b/tools/tests/skimage_self_test.py index cb66fe1729..24164d4a51 100755 --- a/tools/tests/skimage_self_test.py +++ b/tools/tests/skimage_self_test.py @@ -9,6 +9,7 @@ import filecmp import os import subprocess import sys +import tempfile class BinaryNotFoundException(Exception): def __str__ (self): @@ -70,6 +71,26 @@ def main(): # 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!" |