Chromium Code Reviews| Index: tools/tests/skimage_self_test.py |
| diff --git a/tools/tests/skimage_self_test.py b/tools/tests/skimage_self_test.py |
| index cb66fe1729f51c6e10c40bbed482c72b3be5e32a..fdf5e6ebdf460c0317663f85ec309cb89b3a7ef9 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): |
| @@ -51,8 +52,13 @@ def main(): |
| # Generate an expectations file from known images. |
| images_dir = os.path.join(file_dir, "skimage", "input", |
| "images-with-known-hashes") |
| - expectations_path = os.path.join(file_dir, "skimage", "output-actual", |
| - "create-expectations", "expectations.json") |
| + expectations_dir = os.path.join(file_dir, "skimage", "output-actual", |
| + "create-expectations") |
| + |
| + if not os.path.exists(expectations_dir): |
|
scroggo
2013/06/19 20:27:35
Patch set 3 creates the output directories if they
|
| + os.mkdir(expectations_dir) |
| + |
| + expectations_path = os.path.join(expectations_dir, "expectations.json") |
| subprocess.check_call([skimage_binary, "--readPath", images_dir, |
| "--createExpectationsPath", expectations_path]) |
| @@ -70,6 +76,34 @@ 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_dir = os.path.join(file_dir, "skimage", "output-actual", |
| + "empty-dir") |
| + if not os.path.exists(expectations_dir): |
| + os.mkdir(expectations_dir) |
| + |
| + expectations_path = os.path.join(expectations_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_dir = os.path.join(file_dir, "skimage", "output-actual", |
| + "nonexistent-dir") |
| + if not os.path.exists(expectations_dir): |
| + os.mkdir(expectations_dir) |
| + |
| + expectations_path = os.path.join(expectations_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!" |