diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-09 14:48:45 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-09 14:48:45 +0000 |
commit | 0f8171ef4747858c9702005cf73e4890e9cfb931 (patch) | |
tree | 76b632271528b76bb9d97d930f37a669c0a8c04d | |
parent | a2094171817c406b5140e32eaf1ad80156e3f3f1 (diff) | |
download | chromium_src-0f8171ef4747858c9702005cf73e4890e9cfb931.zip chromium_src-0f8171ef4747858c9702005cf73e4890e9cfb931.tar.gz chromium_src-0f8171ef4747858c9702005cf73e4890e9cfb931.tar.bz2 |
Fix python scripts in src/webkit
Make sure that:
- shebang is only present for executable files
- shebang is #!/usr/bin/env python
- __main__ is only present for executable files
- file's executable bit is coherent
Also fix EOF LF to be only one.
TBR=dpranke@chromium.org
BUG=105108
TEST=
Review URL: http://codereview.chromium.org/8678022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@116864 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | webkit/build/webkit_version.py | 11 | ||||
-rw-r--r-- | webkit/data/dom_serializer/dummy.exe | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | webkit/support/setup_third_party.py | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | webkit/tools/layout_tests/run_http_server.py | 2 | ||||
-rwxr-xr-x | webkit/tools/leak_tests/run_node_leak_test.py | 279 | ||||
-rw-r--r-- | webkit/tools/leak_tests/test_lists/alexa_100.txt | 92 |
6 files changed, 10 insertions, 378 deletions
diff --git a/webkit/build/webkit_version.py b/webkit/build/webkit_version.py index 7fdf9b32..ad07f0d 100755 --- a/webkit/build/webkit_version.py +++ b/webkit/build/webkit_version.py @@ -1,5 +1,5 @@ -#!/usr/bin/python -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -49,6 +49,7 @@ def ReadVersionFile(fname): assert(major >= 0 and minor >= 0) return (major, minor) + def GetWebKitRevision(webkit_dir, version_file): """Get the WebKit revision, in the form 'trunk@1234'.""" @@ -95,10 +96,12 @@ def EmitVersionHeader(webkit_dir, version_file, output_dir): """ % (version_file, major, minor, webkit_revision) f.write(template) f.close() + return 0 + def main(): - EmitVersionHeader(*sys.argv[1:]) + return EmitVersionHeader(*sys.argv[1:]) if __name__ == "__main__": - main() + sys.exit(main()) diff --git a/webkit/data/dom_serializer/dummy.exe b/webkit/data/dom_serializer/dummy.exe deleted file mode 100644 index e69de29..0000000 --- a/webkit/data/dom_serializer/dummy.exe +++ /dev/null diff --git a/webkit/support/setup_third_party.py b/webkit/support/setup_third_party.py index b33c14c..fcfae06 100644..100755 --- a/webkit/support/setup_third_party.py +++ b/webkit/support/setup_third_party.py @@ -1,5 +1,5 @@ -#!/usr/bin/python -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +#!/usr/bin/env python +# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/webkit/tools/layout_tests/run_http_server.py b/webkit/tools/layout_tests/run_http_server.py index d7eadc6..a725dd4 100644..100755 --- a/webkit/tools/layout_tests/run_http_server.py +++ b/webkit/tools/layout_tests/run_http_server.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (c) 2010 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. diff --git a/webkit/tools/leak_tests/run_node_leak_test.py b/webkit/tools/leak_tests/run_node_leak_test.py deleted file mode 100755 index f45869a..0000000 --- a/webkit/tools/leak_tests/run_node_leak_test.py +++ /dev/null @@ -1,279 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Run node leak tests using the test_shell. - -TODO(pjohnson): Add a way for layout tests (and other local files in the -working copy) to be easily run by specifying paths relative to webkit (or -something similar). -""" - -import logging -import optparse -import os -import random -import re -import sys - -import google.logging_utils -import google.path_utils -import google.platform_utils -import google.process_utils - -# Magic exit code to indicate a new fix. -REBASELINE_EXIT_CODE = -88 - -# Status codes. -PASS, FAIL, REBASELINE = range(3) - -# The test list files are found in this subdirectory, which must be a sibling -# to this script itself. -TEST_FILE_DIR = 'test_lists' - -# TODO(pjohnson): Find a way to avoid this duplicate code. This function has -# been shamelessly taken from layout_tests/layout_package. -_webkit_root = None - -def WebKitRoot(): - """Returns the full path to the directory containing webkit.sln. Raises - PathNotFound if we're unable to find webkit.sln. - """ - - global _webkit_root - if _webkit_root: - return _webkit_root - webkit_sln_path = google.path_utils.FindUpward(google.path_utils.ScriptDir(), - 'webkit.sln') - _webkit_root = os.path.dirname(webkit_sln_path) - return _webkit_root - -def GetAbsolutePath(path): - platform_util = google.platform_utils.PlatformUtility(WebKitRoot()) - return platform_util.GetAbsolutePath(path) - -# TODO(pjohnson): Find a way to avoid this duplicated code. This function has -# been mostly copied from another function, TestShellBinary, in -# layout_tests/layout_package. -def TestShellTestBinary(target): - """Gets the full path to the test_shell_tests binary for the target build - configuration. Raises PathNotFound if the file doesn't exist. - """ - - full_path = os.path.join(WebKitRoot(), target, 'test_shell_tests.exe') - if not os.path.exists(full_path): - # Try chrome's output directory in case test_shell was built by chrome.sln. - full_path = google.path_utils.FindUpward(WebKitRoot(), 'chrome', target, - 'test_shell_tests.exe') - if not os.path.exists(full_path): - raise PathNotFound('unable to find test_shell_tests at %s' % full_path) - return full_path - -class NodeLeakTestRunner: - """A class for managing running a series of node leak tests. - """ - - def __init__(self, options, urls): - """Collect a list of URLs to test. - - Args: - options: a dictionary of command line options - urls: a list of URLs in the format: - (url, expected_node_leaks, expected_js_leaks) tuples - """ - - self._options = options - self._urls = urls - - self._test_shell_test_binary = TestShellTestBinary(options.target) - - self._node_leak_matcher = re.compile('LEAK: (\d+) Node') - self._js_leak_matcher = re.compile('Leak (\d+) JS wrappers') - - def RunCommand(self, command): - def FindMatch(line, matcher, group_number): - match = matcher.match(line) - if match: - return int(match.group(group_number)) - return 0 - - (code, output) = google.process_utils.RunCommandFull(command, verbose=True, - collect_output=True, - print_output=False) - node_leaks = 0 - js_leaks = 0 - - # Print a row of dashes. - if code != 0: - print '-' * 75 - print 'OUTPUT' - print - - for line in output: - # Sometimes multiple leak lines are printed out, which is why we - # accumulate them here. - node_leaks += FindMatch(line, self._node_leak_matcher, 1) - js_leaks += FindMatch(line, self._js_leak_matcher, 1) - - # If the code indicates there was an error, print the output to help - # figure out what happened. - if code != 0: - print line - - # Print a row of dashes. - if code != 0: - print '-' * 75 - print - - return (code, node_leaks, js_leaks) - - def RunUrl(self, test_url, expected_node_leaks, expected_js_leaks): - shell_args = ['--gtest_filter=NodeLeakTest.*TestURL', - '--time-out-ms=' + str(self._options.time_out_ms), - '--test-url=' + test_url, - '--playback-mode'] - - if self._options.cache_dir != '': - shell_args.append('--cache-dir=' + self._options.cache_dir) - - command = [self._test_shell_test_binary] + shell_args - (exit_code, actual_node_leaks, actual_js_leaks) = self.RunCommand(command) - - logging.info('%s\n' % test_url) - - if exit_code != 0: - # There was a crash, or something else went wrong, so duck out early. - logging.error('Test returned: %d\n' % exit_code) - return FAIL - - result = ('TEST RESULT\n' - ' Node Leaks: %d (actual), %d (expected)\n' - ' JS Leaks: %d (actual), %d (expected)\n' % - (actual_node_leaks, expected_node_leaks, - actual_js_leaks, expected_js_leaks)) - - success = (actual_node_leaks <= expected_node_leaks and - actual_js_leaks <= expected_js_leaks) - - if success: - logging.info(result) - else: - logging.error(result) - logging.error('Unexpected leaks found!\n') - return FAIL - - if (expected_node_leaks > actual_node_leaks or - expected_js_leaks > actual_js_leaks): - logging.warn('Expectations may need to be re-baselined.\n') - # TODO(pjohnson): Return REBASELINE here once bug 1177263 is fixed and - # the expectations have been lowered again. - - return PASS - - def Run(self): - status = PASS - results = [0, 0, 0] - failed_urls = [] - rebaseline_urls = [] - - for (test_url, expected_node_leaks, expected_js_leaks) in self._urls: - result = self.RunUrl(test_url, expected_node_leaks, expected_js_leaks) - if result == PASS: - results[PASS] += 1 - elif result == FAIL: - results[FAIL] += 1 - failed_urls.append(test_url) - status = FAIL - elif result == REBASELINE: - results[REBASELINE] += 1 - rebaseline_urls.append(test_url) - if status != FAIL: - status = REBASELINE - return (status, results, failed_urls, rebaseline_urls) - -def main(options, args): - if options.seed != None: - random.seed(options.seed) - - # Set up logging so any messages below logging.WARNING are sent to stdout, - # otherwise they are sent to stderr. - google.logging_utils.config_root(level=logging.INFO, - threshold=logging.WARNING) - - if options.url_list == '': - logging.error('URL test list required') - sys.exit(1) - - url_list = os.path.join(os.path.dirname(sys.argv[0]), TEST_FILE_DIR, - options.url_list) - url_list = GetAbsolutePath(url_list); - - lines = [] - file = None - try: - file = open(url_list, 'r') - lines = file.readlines() - finally: - if file != None: - file.close() - - expected_matcher = re.compile('(\d+)\s*,\s*(\d+)') - - urls = [] - for line in lines: - line = line.strip() - if len(line) == 0 or line.startswith('#'): - continue - list = line.rsplit('=', 1) - if len(list) < 2: - logging.error('Line "%s" is not formatted correctly' % line) - continue - match = expected_matcher.match(list[1].strip()) - if not match: - logging.error('Line "%s" is not formatted correctly' % line) - continue - urls.append((list[0].strip(), int(match.group(1)), int(match.group(2)))) - - random.shuffle(urls) - runner = NodeLeakTestRunner(options, urls) - (status, results, failed_urls, rebaseline_urls) = runner.Run() - - logging.info('SUMMARY\n' - ' %d passed\n' - ' %d failed\n' - ' %d re-baseline\n' % - (results[0], results[1], results[2])) - - if len(failed_urls) > 0: - failed_string = '\n'.join(' ' + url for url in failed_urls) - logging.error('FAILED URLs\n%s\n' % failed_string) - - if len(rebaseline_urls) > 0: - rebaseline_string = '\n'.join(' ' + url for url in rebaseline_urls) - logging.warn('RE-BASELINE URLs\n%s\n' % rebaseline_string) - - if status == FAIL: - return 1 - elif status == REBASELINE: - return REBASELINE_EXIT_CODE - return 0 - -if '__main__' == __name__: - option_parser = optparse.OptionParser() - option_parser.add_option('', '--target', default='Debug', - help='build target (Debug or Release)') - option_parser.add_option('', '--cache-dir', default='', - help='use a specified cache directory') - option_parser.add_option('', '--url-list', default='', - help='URL input file, with leak expectations, ' - 'relative to webkit/tools/leak_tests') - option_parser.add_option('', '--time-out-ms', default=30000, - help='time out for each test') - option_parser.add_option('', '--seed', default=None, - help='seed for random number generator, use to ' - 'reproduce the exact same order for a ' - 'specific run') - options, args = option_parser.parse_args() - sys.exit(main(options, args)) - diff --git a/webkit/tools/leak_tests/test_lists/alexa_100.txt b/webkit/tools/leak_tests/test_lists/alexa_100.txt deleted file mode 100644 index 8c04a02..0000000 --- a/webkit/tools/leak_tests/test_lists/alexa_100.txt +++ /dev/null @@ -1,92 +0,0 @@ -# Format: URL = EXPECTED_NODE_LEAKS, EXPECTED_JS_LEAKS -# -# This is a list of the top 100 Alexa URLs (as of 3/28/2008) that loaded -# successfully into our saved cache. -# -# Flaky URLs are covered by bug 1177263. -# Since this test is so flaky, for now set the expected numbers very high to -# catch only the most egregious regressions. - -http://www.yahoo.com = 200,200 -http://www.youtube.com = 200,200 -http://www.live.com = 200,200 -http://www.google.com = 200,200 -http://www.myspace.com = 200,200 -http://www.facebook.com = 200,200 -http://www.msn.com = 200,200 -http://www.hi5.com = 200,200 -http://www.wikipedia.org = 200,200 -http://www.orkut.com = 200,200 -http://www.blogger.com = 200,200 -http://www.fotolog.net = 200,200 -http://www.google.fr = 200,200 -http://www.friendster.com = 200,200 -http://www.microsoft.com = 200,200 -http://www.baidu.com = 200,200 -http://www.megarotic.com = 200,200 -http://www.google.cl = 200,200 -http://www.yahoo.co.jp = 200,200 -http://www.ebay.com = 200,200 -http://www.google.com.br = 200,200 -http://www.google.es = 200,200 -http://www.seznam.cz = 200,200 -http://www.google.com.mx = 200,200 -http://www.dailymotion.com = 200,200 -http://www.photobucket.com = 200,200 -http://www.youporn.com = 200,200 -http://www.imdb.com = 200,200 -http://www.google.pl = 200,200 -http://www.qq.com = 200,200 -http://www.google.co.uk = 200,200 -http://www.flickr.com = 200,200 -http://www.vkontakte.ru = 200,200 -http://www.nasza-klasa.pl = 200,200 -http://www.odnoklassniki.ru = 200,200 -http://www.google.de = 200,200 -http://www.metroflog.com = 200,200 -http://www.google.co.ve = 200,200 -http://www.google.com.ar = 200,200 -http://www.free.fr = 200,200 -http://www.wordpress.com = 200,200 -http://www.wretch.cc = 200,200 -http://www.mininova.org = 200,200 -http://www.onet.pl = 200,200 -http://www.google.com.pe = 200,200 -http://www.aol.com = 200,200 -http://www.google.com.co = 200,200 -http://www.allegro.pl = 200,200 -http://www.yandex.ru = 200,200 -http://www.deviantart.com = 200,200 -http://www.sina.com.cn = 200,200 -http://www.google.co.in = 200,200 -http://www.bbc.co.uk = 200,200 -http://www.google.ca = 200,200 -http://www.craigslist.org = 200,200 -http://www.google.sk = 200,200 -http://www.livejournal.com = 200,200 -http://www.iwiw.hu = 200,200 -http://www.google.com.vn = 200,200 -http://www.globo.com = 200,200 -http://www.wp.pl = 200,200 -http://www.netlog.com = 200,200 -http://www.perfspot.com = 200,200 -http://www.googlesyndication.com = 200,200 -http://www.google.it = 200,200 -http://www.google.co.hu = 200,200 -http://www.fc2.com = 200,200 -http://www.google.cn = 200,200 -http://www.ebay.fr = 200,200 -http://www.veoh.com = 200,200 -http://www.google.co.th = 200,200 -http://www.fotka.pl = 200,200 -http://www.orange.fr = 200,200 -http://www.google.com.tr = 200,200 -http://www.geocities.com = 200,200 -http://www.apple.com = 200,200 -http://www.onemanga.com = 200,200 -http://www.ebay.de = 200,200 -http://www.google.co.jp = 200,200 -http://www.taobao.com = 200,200 -http://www.megaflirt.com = 200,200 -http://www.ebay.co.uk = 200,200 -http://www.sexyono.com = 200,200 |