OLD | NEW |
1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 23 matching lines...) Expand all Loading... |
34 import sys | 34 import sys |
35 | 35 |
36 from webkitpy.common.system.executive import Executive | 36 from webkitpy.common.system.executive import Executive |
37 from webkitpy.common.system.filesystem import FileSystem | 37 from webkitpy.common.system.filesystem import FileSystem |
38 from webkitpy.common.webkit_finder import WebKitFinder | 38 from webkitpy.common.webkit_finder import WebKitFinder |
39 | 39 |
40 _log = logging.getLogger(__name__) | 40 _log = logging.getLogger(__name__) |
41 | 41 |
42 | 42 |
43 class Bucket(object): | 43 class Bucket(object): |
| 44 |
44 def __init__(self, tests): | 45 def __init__(self, tests): |
45 self.tests = tests | 46 self.tests = tests |
46 | 47 |
47 def size(self): | 48 def size(self): |
48 return len(self.tests) | 49 return len(self.tests) |
49 | 50 |
50 | 51 |
51 class Bisector(object): | 52 class Bisector(object): |
52 | 53 |
53 def __init__(self, tests, is_debug): | 54 def __init__(self, tests, is_debug): |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 count = 0 | 93 count = 0 |
93 for bucket in self.buckets: | 94 for bucket in self.buckets: |
94 count += len(bucket.tests) | 95 count += len(bucket.tests) |
95 print '%d tests left, %d buckets' % (count, len(self.buckets)) | 96 print '%d tests left, %d buckets' % (count, len(self.buckets)) |
96 | 97 |
97 def print_result(self): | 98 def print_result(self): |
98 tests = [] | 99 tests = [] |
99 for bucket in self.buckets: | 100 for bucket in self.buckets: |
100 tests += bucket.tests | 101 tests += bucket.tests |
101 extra_args = ' --debug' if self.is_debug else '' | 102 extra_args = ' --debug' if self.is_debug else '' |
102 print 'run-webkit-tests%s --child-processes=1 --order=none %s' % (extra_
args, " ".join(tests)) | 103 print 'run-webkit-tests%s --child-processes=1 --order=none %s' % (extra_
args, ' '.join(tests)) |
103 | 104 |
104 def is_done(self): | 105 def is_done(self): |
105 for bucket in self.buckets: | 106 for bucket in self.buckets: |
106 if bucket.size() > 1: | 107 if bucket.size() > 1: |
107 return False | 108 return False |
108 return True | 109 return True |
109 | 110 |
110 def split_largest_bucket(self): | 111 def split_largest_bucket(self): |
111 index = 0 | 112 index = 0 |
112 largest_index = 0 | 113 largest_index = 0 |
(...skipping 27 matching lines...) Expand all Loading... |
140 | 141 |
141 def test_bucket_list_fails(self, buckets): | 142 def test_bucket_list_fails(self, buckets): |
142 tests = [] | 143 tests = [] |
143 for bucket in buckets: | 144 for bucket in buckets: |
144 tests += bucket.tests | 145 tests += bucket.tests |
145 return self.test_fails(tests) | 146 return self.test_fails(tests) |
146 | 147 |
147 def test_fails(self, tests): | 148 def test_fails(self, tests): |
148 extra_args = ['--debug'] if self.is_debug else [] | 149 extra_args = ['--debug'] if self.is_debug else [] |
149 path_to_run_webkit_tests = self.webkit_finder.path_from_webkit_base('Too
ls', 'Scripts', 'run-webkit-tests') | 150 path_to_run_webkit_tests = self.webkit_finder.path_from_webkit_base('Too
ls', 'Scripts', 'run-webkit-tests') |
150 output = self.executive.popen([path_to_run_webkit_tests, '--child-proces
ses', '1', '--order', 'none', '--no-retry', '--no-show-results', '--verbose'] +
extra_args + tests, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 151 output = self.executive.popen([path_to_run_webkit_tests, |
| 152 '--child-processes', |
| 153 '1', |
| 154 '--order', |
| 155 'none', |
| 156 '--no-retry', |
| 157 '--no-show-results', |
| 158 '--verbose'] + extra_args + tests, |
| 159 stdout=subprocess.PIPE, |
| 160 stderr=subprocess.PIPE) |
151 failure_string = self.expected_failure + ' failed' | 161 failure_string = self.expected_failure + ' failed' |
152 if failure_string in output.stderr.read(): | 162 if failure_string in output.stderr.read(): |
153 return True | 163 return True |
154 return False | 164 return False |
155 | 165 |
156 | 166 |
157 def main(argv): | 167 def main(argv): |
158 logging.basicConfig() | 168 logging.basicConfig() |
159 | 169 |
160 option_parser = optparse.OptionParser() | 170 option_parser = optparse.OptionParser() |
161 option_parser.add_option('--test-list', action='store', help='file that list
tests to bisect. The last test in the list is the expected failure.', metavar='
FILE'), | 171 option_parser.add_option( |
| 172 '--test-list', |
| 173 action='store', |
| 174 help='file that list tests to bisect. The last test in the list is the e
xpected failure.', |
| 175 metavar='FILE'), |
162 option_parser.add_option('--debug', action='store_true', default=False, help
='whether to use a debug build'), | 176 option_parser.add_option('--debug', action='store_true', default=False, help
='whether to use a debug build'), |
163 options, args = option_parser.parse_args(argv) | 177 options, args = option_parser.parse_args(argv) |
164 | 178 |
165 tests = open(options.test_list).read().strip().split('\n') | 179 tests = open(options.test_list).read().strip().split('\n') |
166 bisector = Bisector(tests, is_debug=options.debug) | 180 bisector = Bisector(tests, is_debug=options.debug) |
167 return bisector.bisect() | 181 return bisector.bisect() |
168 | 182 |
169 if __name__ == '__main__': | 183 if __name__ == '__main__': |
170 sys.exit(main(sys.argv[1:])) | 184 sys.exit(main(sys.argv[1:])) |
OLD | NEW |