Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
|
scroggo
2013/05/09 15:50:43
I noticed that gm's self test has a note that it s
epoger
2013/05/09 16:35:50
Yes, good idea to do it that way in the first plac
| |
| 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 | |
| 11 # Use the directory of this file as the out directory | |
|
epoger
2013/05/09 16:35:50
I think it would be better to write test files int
scroggo
2013/05/09 19:05:59
Done.
| |
| 12 out_dir = os.path.dirname(__file__) | |
| 13 out_dir = os.path.abspath(out_dir) | |
| 14 | |
| 15 # Move up to trunk | |
| 16 old_working_dir = os.getcwd() | |
| 17 os.chdir(out_dir) | |
| 18 os.chdir('../../../') | |
| 19 | |
| 20 # Find the binary | |
| 21 skimage_binary = None | |
| 22 xcode_path = "xcodebuild/Debug/skimage" | |
| 23 gcc_path = "out/Debug/skimage" | |
|
scroggo
2013/05/09 15:50:43
It looks like gm's self test assumes you have alre
epoger
2013/05/09 16:35:50
Yeah, it's a tough call, because individual develo
| |
| 24 | |
| 25 if (os.path.exists(gcc_path)): | |
|
epoger
2013/05/09 16:35:50
Good idea to go looking for the binary in differen
scroggo
2013/05/09 19:05:59
I have added a function to find the binary. I also
| |
| 26 skimage_binary = gcc_path | |
| 27 elif (os.path.exists(xcode_path)): | |
| 28 skimage_binary = xcode_path | |
| 29 | |
| 30 resultsFile = None | |
| 31 | |
| 32 if (skimage_binary != None): | |
| 33 try: | |
| 34 # Run skimage twice, first to create an expectations file, and then | |
| 35 # comparing to it. | |
| 36 # Both commands will run the binary, reading from resources. | |
| 37 cmd_line = [skimage_binary] | |
| 38 cmd_line.extend(["-r", "resources/CMYK.jpg", "resources/plane.png"]) | |
|
epoger
2013/05/09 16:35:50
Alternatively, you could assemble these paths as a
scroggo
2013/05/09 19:05:59
Done.
| |
| 39 # Create the expectations file | |
| 40 create_expectations_cmd = cmd_line + ["--createExpectationsPath", out_di r] | |
| 41 subprocess.check_call(create_expectations_cmd) | |
|
scroggo
2013/05/09 15:57:29
There are some commands for calling programs more
epoger
2013/05/09 16:35:50
Unfortunately, no. Most developers will have chec
scroggo
2013/05/09 19:05:59
That sounds reasonable to me. Probably outside of
epoger
2013/05/09 19:19:39
Definitely outside the scope of this CL. Please c
| |
| 42 # Now read from the expectations file | |
| 43 resultsFile = os.path.join(out_dir, "results.json") | |
| 44 check_expectations_cmd = cmd_line + ["--readExpectationsPath", resultsFi le] | |
|
epoger
2013/05/09 16:35:50
Great! This is definitely a good start... but, if
scroggo
2013/05/09 19:05:59
Definitely the long term plan is to compare agains
epoger
2013/05/09 19:19:39
To some extent, we may be able to have expectation
| |
| 45 subprocess.check_call(check_expectations_cmd) | |
| 46 print "Self tests succeeded!" | |
| 47 except subprocess.CalledProcessError as e: | |
| 48 print skimage_binary + " failed with error code " + str(e.returncode) | |
| 49 print "Self tests failed!" | |
|
epoger
2013/05/09 16:35:50
It would be better if the process exited with a no
scroggo
2013/05/09 19:05:59
Done.
| |
| 50 else: | |
| 51 print "Could not find skimage binary!" | |
| 52 print "Did you forget to build tools project?" | |
| 53 print "Self tests failed" | |
| 54 | |
| 55 # Delete the results file, which is no longer needed. | |
| 56 if (resultsFile != None and os.path.exists(resultsFile)): | |
| 57 os.remove(resultsFile) | |
| 58 | |
| 59 # Return to the original working directory. | |
| 60 os.chdir(old_working_dir) | |
| OLD | NEW |