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

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

Issue 14969007: Create a self test for skimage. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Use os.pardir to represent the parent directory. Created 7 years, 7 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
« no previous file with comments | « tools/tests/skimage/README ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 # Self-test for skimage.
7
8 import os
9 import subprocess
10 import sys
11
12 class BinaryNotFoundException(Exception):
13 def __str__ (self):
14 return "Could not find binary!\nDid you forget to build the tools projec t?\n" \
epoger 2013/05/14 15:24:45 or, I think this will also appease the Python inte
scroggo 2013/05/14 17:49:38 Done.
15 + "Self tests failed"
16
17 # Find a path to the binary to use. Iterates through a list of possible
18 # locations the binary may be.
19 def PickBinaryPath(base_dir):
20 POSSIBLE_BINARY_PATHS = [
21 'out/Debug/skimage',
22 'out/Release/skimage',
23 'xcodebuild/Debug/skimage',
24 'xcodebuild/Release/skimage',
25 ]
26 for binary in POSSIBLE_BINARY_PATHS:
27 binary_full_path = os.path.join(base_dir, binary)
28 if (os.path.exists(binary_full_path)):
29 return binary_full_path
30 raise BinaryNotFoundException
31
32 def main():
33 # Use the directory of this file as the out directory
34 file_dir = os.path.abspath(os.path.dirname(__file__))
35
36 trunk_dir = os.path.normpath(os.path.join(file_dir, os.pardir, os.pardir))
37
38 # Find the binary
39 skimage_binary = PickBinaryPath(trunk_dir)
40
41 print "Running " + skimage_binary
42 # Run skimage twice, first to create an expectations file, and then
epoger 2013/05/14 15:24:45 IMHO, this would be easier to read with a newline
scroggo 2013/05/14 17:49:38 Done.
43 # comparing to it.
44 # Both commands will run the binary, reading from resources.
45 cmd_line = [skimage_binary]
46 resources_dir = os.path.join(trunk_dir, 'resources')
47 cmd_line.extend(["-r", resources_dir])
48 # Create the expectations file
49 results_dir = os.path.join(file_dir, "skimage")
50 create_expectations_cmd = cmd_line + ["--createExpectationsPath", results_di r]
51 subprocess.check_call(create_expectations_cmd)
52 # Now read from the expectations file
53 results_file = os.path.join(results_dir, "results.json")
54 check_expectations_cmd = cmd_line + ["--readExpectationsPath", results_file]
55 subprocess.check_call(check_expectations_cmd)
56 print "Self tests succeeded!"
57
58 if __name__ == "__main__":
59 main()
OLDNEW
« no previous file with comments | « tools/tests/skimage/README ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698