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

Side by Side Diff: tools/test_rendering.py

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

Powered by Google App Engine
This is Rietveld 408576698