Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: tools/tests/skimage_self_test.py

Issue 17294006: skimage: if --readPath points at an empty dir, create an empty expectations file (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # Self-test for skimage. 6 # Self-test for skimage.
7 7
8 import filecmp 8 import filecmp
9 import os 9 import os
10 import subprocess 10 import subprocess
11 import sys 11 import sys
12 import tempfile
12 13
13 class BinaryNotFoundException(Exception): 14 class BinaryNotFoundException(Exception):
14 def __str__ (self): 15 def __str__ (self):
15 return ("Could not find binary!\n" 16 return ("Could not find binary!\n"
16 "Did you forget to build the tools project?\n" 17 "Did you forget to build the tools project?\n"
17 "Self tests failed") 18 "Self tests failed")
18 19
19 # Find a path to the binary to use. Iterates through a list of possible 20 # Find a path to the binary to use. Iterates through a list of possible
20 # locations the binary may be. 21 # locations the binary may be.
21 def PickBinaryPath(base_dir): 22 def PickBinaryPath(base_dir):
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 DieIfFilesMismatch(expected=golden_expectations, actual=expectations_path) 64 DieIfFilesMismatch(expected=golden_expectations, actual=expectations_path)
64 65
65 # Tell skimage to read back the expectations file it just wrote, and 66 # Tell skimage to read back the expectations file it just wrote, and
66 # confirm that the images in images_dir match it. 67 # confirm that the images in images_dir match it.
67 subprocess.check_call([skimage_binary, "--readPath", images_dir, 68 subprocess.check_call([skimage_binary, "--readPath", images_dir,
68 "--readExpectationsPath", expectations_path]) 69 "--readExpectationsPath", expectations_path])
69 70
70 # TODO(scroggo): Add a test that compares expectations and image files that 71 # TODO(scroggo): Add a test that compares expectations and image files that
71 # are known to NOT match, and make sure it returns an error. 72 # are known to NOT match, and make sure it returns an error.
72 73
74 # Generate an expectations file from an empty directory.
75 empty_dir = tempfile.mkdtemp()
76 expectations_path = os.path.join(file_dir, "skimage", "output-actual",
77 "empty-dir", "expectations.json")
78 subprocess.check_call([skimage_binary, "--readPath", empty_dir,
79 "--createExpectationsPath", expectations_path])
80 golden_expectations = os.path.join(file_dir, "skimage", "output-expected",
81 "empty-dir", "expectations.json")
82 DieIfFilesMismatch(expected=golden_expectations, actual=expectations_path)
83 os.rmdir(empty_dir)
84
85 # Generate an expectations file from a nonexistent directory.
86 expectations_path = os.path.join(file_dir, "skimage", "output-actual",
87 "nonexistent-dir", "expectations.json")
88 subprocess.check_call([skimage_binary, "--readPath", "/nonexistent/dir",
89 "--createExpectationsPath", expectations_path])
90 golden_expectations = os.path.join(file_dir, "skimage", "output-expected",
91 "nonexistent-dir", "expectations.json")
92 DieIfFilesMismatch(expected=golden_expectations, actual=expectations_path)
93
73 # Done with all tests. 94 # Done with all tests.
74 print "Self tests succeeded!" 95 print "Self tests succeeded!"
75 96
76 if __name__ == "__main__": 97 if __name__ == "__main__":
77 main() 98 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698