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

Side by Side Diff: webkit/tools/leak_tests/run_node_leak_test.py

Issue 8678022: Fix python scripts in src/webkit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years 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/python 1 #!/usr/bin/env python
Dirk Pranke 2011/11/23 21:29:15 I bet this can go, too.
2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2006-2008 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 """Run node leak tests using the test_shell. 6 """Run node leak tests using the test_shell.
7 7
8 TODO(pjohnson): Add a way for layout tests (and other local files in the 8 TODO(pjohnson): Add a way for layout tests (and other local files in the
9 working copy) to be easily run by specifying paths relative to webkit (or 9 working copy) to be easily run by specifying paths relative to webkit (or
10 something similar). 10 something similar).
11 """ 11 """
(...skipping 17 matching lines...) Expand all
29 PASS, FAIL, REBASELINE = range(3) 29 PASS, FAIL, REBASELINE = range(3)
30 30
31 # The test list files are found in this subdirectory, which must be a sibling 31 # The test list files are found in this subdirectory, which must be a sibling
32 # to this script itself. 32 # to this script itself.
33 TEST_FILE_DIR = 'test_lists' 33 TEST_FILE_DIR = 'test_lists'
34 34
35 # TODO(pjohnson): Find a way to avoid this duplicate code. This function has 35 # TODO(pjohnson): Find a way to avoid this duplicate code. This function has
36 # been shamelessly taken from layout_tests/layout_package. 36 # been shamelessly taken from layout_tests/layout_package.
37 _webkit_root = None 37 _webkit_root = None
38 38
39
39 def WebKitRoot(): 40 def WebKitRoot():
40 """Returns the full path to the directory containing webkit.sln. Raises 41 """Returns the full path to the directory containing webkit.sln. Raises
41 PathNotFound if we're unable to find webkit.sln. 42 PathNotFound if we're unable to find webkit.sln.
42 """ 43 """
43 44
44 global _webkit_root 45 global _webkit_root
45 if _webkit_root: 46 if _webkit_root:
46 return _webkit_root 47 return _webkit_root
47 webkit_sln_path = google.path_utils.FindUpward(google.path_utils.ScriptDir(), 48 webkit_sln_path = google.path_utils.FindUpward(google.path_utils.ScriptDir(),
48 'webkit.sln') 49 'webkit.sln')
(...skipping 14 matching lines...) Expand all
63 64
64 full_path = os.path.join(WebKitRoot(), target, 'test_shell_tests.exe') 65 full_path = os.path.join(WebKitRoot(), target, 'test_shell_tests.exe')
65 if not os.path.exists(full_path): 66 if not os.path.exists(full_path):
66 # Try chrome's output directory in case test_shell was built by chrome.sln. 67 # Try chrome's output directory in case test_shell was built by chrome.sln.
67 full_path = google.path_utils.FindUpward(WebKitRoot(), 'chrome', target, 68 full_path = google.path_utils.FindUpward(WebKitRoot(), 'chrome', target,
68 'test_shell_tests.exe') 69 'test_shell_tests.exe')
69 if not os.path.exists(full_path): 70 if not os.path.exists(full_path):
70 raise PathNotFound('unable to find test_shell_tests at %s' % full_path) 71 raise PathNotFound('unable to find test_shell_tests at %s' % full_path)
71 return full_path 72 return full_path
72 73
73 class NodeLeakTestRunner: 74
75 class NodeLeakTestRunner(object):
74 """A class for managing running a series of node leak tests. 76 """A class for managing running a series of node leak tests.
75 """ 77 """
76 78
77 def __init__(self, options, urls): 79 def __init__(self, options, urls):
78 """Collect a list of URLs to test. 80 """Collect a list of URLs to test.
79 81
80 Args: 82 Args:
81 options: a dictionary of command line options 83 options: a dictionary of command line options
82 urls: a list of URLs in the format: 84 urls: a list of URLs in the format:
83 (url, expected_node_leaks, expected_js_leaks) tuples 85 (url, expected_node_leaks, expected_js_leaks) tuples
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 results[FAIL] += 1 187 results[FAIL] += 1
186 failed_urls.append(test_url) 188 failed_urls.append(test_url)
187 status = FAIL 189 status = FAIL
188 elif result == REBASELINE: 190 elif result == REBASELINE:
189 results[REBASELINE] += 1 191 results[REBASELINE] += 1
190 rebaseline_urls.append(test_url) 192 rebaseline_urls.append(test_url)
191 if status != FAIL: 193 if status != FAIL:
192 status = REBASELINE 194 status = REBASELINE
193 return (status, results, failed_urls, rebaseline_urls) 195 return (status, results, failed_urls, rebaseline_urls)
194 196
195 def main(options, args): 197
198 def run_node_leak_test(options, args):
196 if options.seed != None: 199 if options.seed != None:
197 random.seed(options.seed) 200 random.seed(options.seed)
198 201
199 # Set up logging so any messages below logging.WARNING are sent to stdout, 202 # Set up logging so any messages below logging.WARNING are sent to stdout,
200 # otherwise they are sent to stderr. 203 # otherwise they are sent to stderr.
201 google.logging_utils.config_root(level=logging.INFO, 204 google.logging_utils.config_root(level=logging.INFO,
202 threshold=logging.WARNING) 205 threshold=logging.WARNING)
203 206
204 if options.url_list == '': 207 if options.url_list == '':
205 logging.error('URL test list required') 208 logging.error('URL test list required')
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if len(rebaseline_urls) > 0: 255 if len(rebaseline_urls) > 0:
253 rebaseline_string = '\n'.join(' ' + url for url in rebaseline_urls) 256 rebaseline_string = '\n'.join(' ' + url for url in rebaseline_urls)
254 logging.warn('RE-BASELINE URLs\n%s\n' % rebaseline_string) 257 logging.warn('RE-BASELINE URLs\n%s\n' % rebaseline_string)
255 258
256 if status == FAIL: 259 if status == FAIL:
257 return 1 260 return 1
258 elif status == REBASELINE: 261 elif status == REBASELINE:
259 return REBASELINE_EXIT_CODE 262 return REBASELINE_EXIT_CODE
260 return 0 263 return 0
261 264
262 if '__main__' == __name__: 265
266 def main():
263 option_parser = optparse.OptionParser() 267 option_parser = optparse.OptionParser()
264 option_parser.add_option('', '--target', default='Debug', 268 option_parser.add_option('', '--target', default='Debug',
265 help='build target (Debug or Release)') 269 help='build target (Debug or Release)')
266 option_parser.add_option('', '--cache-dir', default='', 270 option_parser.add_option('', '--cache-dir', default='',
267 help='use a specified cache directory') 271 help='use a specified cache directory')
268 option_parser.add_option('', '--url-list', default='', 272 option_parser.add_option('', '--url-list', default='',
269 help='URL input file, with leak expectations, ' 273 help='URL input file, with leak expectations, '
270 'relative to webkit/tools/leak_tests') 274 'relative to webkit/tools/leak_tests')
271 option_parser.add_option('', '--time-out-ms', default=30000, 275 option_parser.add_option('', '--time-out-ms', default=30000,
272 help='time out for each test') 276 help='time out for each test')
273 option_parser.add_option('', '--seed', default=None, 277 option_parser.add_option('', '--seed', default=None,
274 help='seed for random number generator, use to ' 278 help='seed for random number generator, use to '
275 'reproduce the exact same order for a ' 279 'reproduce the exact same order for a '
276 'specific run') 280 'specific run')
277 options, args = option_parser.parse_args() 281 options, args = option_parser.parse_args()
278 sys.exit(main(options, args)) 282 return run_node_leak_test(options, args)
279 283
284
285 if '__main__' == __name__:
286 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698