OLD | NEW |
1 ''' | 1 ''' |
2 Copyright 2012 Google Inc. | 2 Copyright 2012 Google Inc. |
3 | 3 |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 | 6 |
7 Compares the rendererings of serialized SkPictures to expected result. | 7 Compares the rendererings of serialized SkPictures to expected result. |
8 | 8 |
9 TODO(epoger): Combine with overlapping tools/tests/render_pictures_test.py . | 9 TODO(epoger): We believe this script is no longer used, so we have disabled it |
| 10 and will remove it on 1 Feb 2014 if nobody objects. |
10 See https://code.google.com/p/skia/issues/detail?id=1943#c2 | 11 See https://code.google.com/p/skia/issues/detail?id=1943#c2 |
11 ''' | 12 ''' |
12 # common Python modules | 13 # common Python modules |
13 import os | 14 import os |
14 import optparse | 15 import optparse |
15 import sys | 16 import sys |
16 import shutil | 17 import shutil |
17 import tempfile | 18 import tempfile |
18 | 19 |
19 USAGE_STRING = 'Usage: %s input... expectedDir render_app [reander_app_args]' | 20 USAGE_STRING = 'Usage: %s input... expectedDir render_app [reander_app_args]' |
20 HELP_STRING = ''' | 21 HELP_STRING = ''' |
21 | 22 |
22 Compares the renderings of serialized SkPicture files and directories specified | 23 Compares the renderings of serialized SkPicture files and directories specified |
23 by input with the files in expectedDir. Note, files in directoriers are | 24 by input with the files in expectedDir. Note, files in directoriers are |
24 expected to end with .skp. | 25 expected to end with .skp. |
25 ''' | 26 ''' |
26 | 27 |
| 28 def _DieBecauseDeprecated(): |
| 29 print ('We believe this script is no longer used, so we have disabled it ' |
| 30 'and will remove it on 1 Feb 2014 if nobody objects. See ' |
| 31 'https://code.google.com/p/skia/issues/detail?id=1943#c2') |
| 32 sys.exit(-1) |
| 33 |
27 def RunCommand(command): | 34 def RunCommand(command): |
28 """Run a command. | 35 """Run a command. |
29 | 36 |
30 @param command the command as a single string | 37 @param command the command as a single string |
31 """ | 38 """ |
| 39 _DieBecauseDeprecated() |
32 print 'running command [%s]...' % command | 40 print 'running command [%s]...' % command |
33 os.system(command) | 41 os.system(command) |
34 | 42 |
35 | 43 |
36 def FindPathToProgram(program): | 44 def FindPathToProgram(program): |
37 """Return path to an existing program binary, or raise an exception if we | 45 """Return path to an existing program binary, or raise an exception if we |
38 cannot find one. | 46 cannot find one. |
39 | 47 |
40 @param program the name of the program that is being looked for | 48 @param program the name of the program that is being looked for |
41 """ | 49 """ |
| 50 _DieBecauseDeprecated() |
42 trunk_path = os.path.abspath(os.path.join(os.path.dirname(__file__), | 51 trunk_path = os.path.abspath(os.path.join(os.path.dirname(__file__), |
43 os.pardir)) | 52 os.pardir)) |
44 possible_paths = [os.path.join(trunk_path, 'out', 'Release', program), | 53 possible_paths = [os.path.join(trunk_path, 'out', 'Release', program), |
45 os.path.join(trunk_path, 'out', 'Debug', program), | 54 os.path.join(trunk_path, 'out', 'Debug', program), |
46 os.path.join(trunk_path, 'out', 'Release', | 55 os.path.join(trunk_path, 'out', 'Release', |
47 program + ".exe"), | 56 program + ".exe"), |
48 os.path.join(trunk_path, 'out', 'Debug', | 57 os.path.join(trunk_path, 'out', 'Debug', |
49 program + ".exe")] | 58 program + ".exe")] |
50 for try_path in possible_paths: | 59 for try_path in possible_paths: |
51 if os.path.isfile(try_path): | 60 if os.path.isfile(try_path): |
52 return try_path | 61 return try_path |
53 raise Exception('cannot find %s in paths %s; maybe you need to ' | 62 raise Exception('cannot find %s in paths %s; maybe you need to ' |
54 'build %s?' % (program, possible_paths, program)) | 63 'build %s?' % (program, possible_paths, program)) |
55 | 64 |
56 | 65 |
57 def RenderSkps(inputs, render_dir, render_app, args): | 66 def RenderSkps(inputs, render_dir, render_app, args): |
58 """Renders the serialized SkPictures. | 67 """Renders the serialized SkPictures. |
59 | 68 |
60 Uses the render_pictures program to do the rendering. | 69 Uses the render_pictures program to do the rendering. |
61 | 70 |
62 @param inputs the location(s) to read the serlialized SkPictures | 71 @param inputs the location(s) to read the serlialized SkPictures |
63 @param render_dir the location to write out the rendered images | 72 @param render_dir the location to write out the rendered images |
64 """ | 73 """ |
| 74 _DieBecauseDeprecated() |
65 renderer_path = FindPathToProgram(render_app) | 75 renderer_path = FindPathToProgram(render_app) |
66 inputs_as_string = " ".join(inputs) | 76 inputs_as_string = " ".join(inputs) |
67 command = '%s %s %s' % (renderer_path, inputs_as_string, render_dir) | 77 command = '%s %s %s' % (renderer_path, inputs_as_string, render_dir) |
68 | 78 |
69 command += args | 79 command += args |
70 | 80 |
71 RunCommand(command) | 81 RunCommand(command) |
72 | 82 |
73 | 83 |
74 def DiffRenderings(expected_dir, comparison_dir, diff_dir): | 84 def DiffRenderings(expected_dir, comparison_dir, diff_dir): |
75 """Diffs the rendered SkPicture files with the baseline files. | 85 """Diffs the rendered SkPicture files with the baseline files. |
76 | 86 |
77 Uses the skdiff program to do the diffing. | 87 Uses the skdiff program to do the diffing. |
78 | 88 |
79 @param expected_dir the location of the baseline images. | 89 @param expected_dir the location of the baseline images. |
80 @param comparison_dir the location of the images to comapre with the | 90 @param comparison_dir the location of the images to comapre with the |
81 baseline | 91 baseline |
82 @param diff_dir the location to write out the diff results | 92 @param diff_dir the location to write out the diff results |
83 """ | 93 """ |
| 94 _DieBecauseDeprecated() |
84 skdiff_path = FindPathToProgram('skdiff') | 95 skdiff_path = FindPathToProgram('skdiff') |
85 RunCommand('%s %s %s %s %s' % | 96 RunCommand('%s %s %s %s %s' % |
86 (skdiff_path, expected_dir, comparison_dir, diff_dir, | 97 (skdiff_path, expected_dir, comparison_dir, diff_dir, |
87 '--noprintdirs')) | 98 '--noprintdirs')) |
88 | 99 |
89 | 100 |
90 def Cleanup(render_dir_option, diff_dir_option, render_dir, diff_dir): | 101 def Cleanup(render_dir_option, diff_dir_option, render_dir, diff_dir): |
91 """Deletes any temporary folders and files created. | 102 """Deletes any temporary folders and files created. |
92 | 103 |
93 @param foo_option The OptionParser parsed render_dir or diff_dir vars. | 104 @param foo_option The OptionParser parsed render_dir or diff_dir vars. |
94 If these variables are not passed by user we ended up creating | 105 If these variables are not passed by user we ended up creating |
95 temporary directories (render_dir, diff_dir) which we will remove. | 106 temporary directories (render_dir, diff_dir) which we will remove. |
96 @param render_dir the directory where the rendered images were written | 107 @param render_dir the directory where the rendered images were written |
97 @param diff_dir the directory where the diff results were written | 108 @param diff_dir the directory where the diff results were written |
98 """ | 109 """ |
| 110 _DieBecauseDeprecated() |
99 if (not render_dir_option): | 111 if (not render_dir_option): |
100 if (os.path.isdir(render_dir)): | 112 if (os.path.isdir(render_dir)): |
101 shutil.rmtree(render_dir) | 113 shutil.rmtree(render_dir) |
102 if (not diff_dir_option): | 114 if (not diff_dir_option): |
103 if (os.path.isdir(diff_dir)): | 115 if (os.path.isdir(diff_dir)): |
104 shutil.rmtree(diff_dir) | 116 shutil.rmtree(diff_dir) |
105 | 117 |
106 def TestRenderSkps(inputs, expected_dir, render_dir_option, diff_dir_option, | 118 def TestRenderSkps(inputs, expected_dir, render_dir_option, diff_dir_option, |
107 render_app, render_args): | 119 render_app, render_args): |
| 120 _DieBecauseDeprecated() |
108 if (render_dir_option): | 121 if (render_dir_option): |
109 render_dir = render_dir_option | 122 render_dir = render_dir_option |
110 else: | 123 else: |
111 render_dir = tempfile.mkdtemp() | 124 render_dir = tempfile.mkdtemp() |
112 | 125 |
113 if (diff_dir_option): | 126 if (diff_dir_option): |
114 diff_dir = diff_dir_option | 127 diff_dir = diff_dir_option |
115 else: | 128 else: |
116 diff_dir = tempfile.mkdtemp() | 129 diff_dir = tempfile.mkdtemp() |
117 try: | 130 try: |
118 RenderSkps(inputs, render_dir, render_app, render_args) | 131 RenderSkps(inputs, render_dir, render_app, render_args) |
119 DiffRenderings(expected_dir, render_dir, diff_dir) | 132 DiffRenderings(expected_dir, render_dir, diff_dir) |
120 finally: | 133 finally: |
121 Cleanup(render_dir_option, diff_dir_option, render_dir, diff_dir) | 134 Cleanup(render_dir_option, diff_dir_option, render_dir, diff_dir) |
OLD | NEW |