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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/w3c/update_w3c_test_expectations.py

Issue 2337183002: Add --help and --verbose options to update-w3c-test-expectations. (Closed)
Patch Set: Remove unrelated files, remove extra parse_args function and a couple logging statements Created 4 years, 3 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
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """A class for updating layout test expectations when updating w3c tests. 5 """A class for updating layout test expectations when updating w3c tests.
6 6
7 Specifically, this class fetches results from try bots for the current CL, and: 7 Specifically, this class fetches results from try bots for the current CL, and:
8 1. Downloads new baseline files for any tests that can be rebaselined. 8 1. Downloads new baseline files for any tests that can be rebaselined.
9 2. Updates the generic TestExpectations file for any other failing tests. 9 2. Updates the generic TestExpectations file for any other failing tests.
10 10
11 This is used as part of the w3c test auto-import process. 11 This is used as part of the w3c test auto-import process.
12 """ 12 """
13 13
14 import argparse
14 import logging 15 import logging
15 16
16 from webkitpy.common.net.buildbot import BuildBot, Build
17 from webkitpy.common.net.git_cl import GitCL 17 from webkitpy.common.net.git_cl import GitCL
18 from webkitpy.common.net.rietveld import Rietveld 18 from webkitpy.common.net.rietveld import Rietveld
19 from webkitpy.common.webkit_finder import WebKitFinder 19 from webkitpy.common.webkit_finder import WebKitFinder
20 from webkitpy.w3c.test_parser import TestParser 20 from webkitpy.w3c.test_parser import TestParser
21 21
22 _log = logging.getLogger(__name__) 22 _log = logging.getLogger(__name__)
23 23
24 24
25 class W3CExpectationsLineAdder(object): 25 class W3CExpectationsLineAdder(object):
26 26
27 def __init__(self, host): 27 def __init__(self, host):
28 self.host = host 28 self.host = host
29 self.host.initialize_scm() 29 self.host.initialize_scm()
30 self.finder = WebKitFinder(self.host.filesystem) 30 self.finder = WebKitFinder(self.host.filesystem)
31 31
32 def run(self): 32 def run(self, args=None):
33 parser = argparse.ArgumentParser(description=__doc__)
34 parser.add_argument('-v', '--verbose', action='store_true', help='More v erbose logging.')
35 args = parser.parse_args(args)
36 log_level = logging.DEBUG if args.verbose else logging.INFO
37 logging.basicConfig(level=log_level, format='%(message)s')
38
33 issue_number = self.get_issue_number() 39 issue_number = self.get_issue_number()
40 if issue_number == 'None':
41 _log.error('No issue on current branch.')
42 return 1
43
34 try_bots = self.get_try_bots() 44 try_bots = self.get_try_bots()
35 rietveld = Rietveld(self.host.web) 45 rietveld = Rietveld(self.host.web)
36 try_jobs = rietveld.latest_try_jobs(issue_number, try_bots) 46 try_jobs = rietveld.latest_try_jobs(issue_number, try_bots)
47 _log.debug('Latest try jobs: %r', try_jobs)
37 48
38 if not try_jobs: 49 if not try_jobs:
39 print 'No Try Job information was collected.' 50 _log.error('No try job information was collected.')
40 return 1 51 return 1
41 52
42 test_expectations = {} 53 test_expectations = {}
43 for job in try_jobs: 54 for job in try_jobs:
44 platform_results = self.get_failing_results_dict(job) 55 platform_results = self.get_failing_results_dict(job)
45 test_expectations = self.merge_dicts(test_expectations, platform_res ults) 56 test_expectations = self.merge_dicts(test_expectations, platform_res ults)
46 57
47 for test_name, platform_result in test_expectations.iteritems(): 58 for test_name, platform_result in test_expectations.iteritems():
48 test_expectations[test_name] = self.merge_same_valued_keys(platform_ result) 59 test_expectations[test_name] = self.merge_same_valued_keys(platform_ result)
49 60
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 Writes the test expectations lines in |line_list| to the test 259 Writes the test expectations lines in |line_list| to the test
249 expectations file. 260 expectations file.
250 261
251 The place in the file where the new lines are inserted is after a 262 The place in the file where the new lines are inserted is after a
252 marker comment line. If this marker comment line is not found, it will 263 marker comment line. If this marker comment line is not found, it will
253 be added to the end of the file. 264 be added to the end of the file.
254 265
255 Args: 266 Args:
256 line_list: A list of w3c test expectations lines. 267 line_list: A list of w3c test expectations lines.
257 """ 268 """
269 _log.debug('Lines to write to TestExpectations: %r', line_list)
258 port = self.host.port_factory.get() 270 port = self.host.port_factory.get()
259 expectations_file = port.path_to_generic_test_expectations_file() 271 expectations_file = port.path_to_generic_test_expectations_file()
260 comment_line = '# Tests added from W3C auto import bot' 272 comment_line = '# Tests added from W3C auto import bot'
261 file_contents = self.host.filesystem.read_text_file(expectations_file) 273 file_contents = self.host.filesystem.read_text_file(expectations_file)
262 w3c_comment_line_index = file_contents.find(comment_line) 274 w3c_comment_line_index = file_contents.find(comment_line)
263 all_lines = '' 275 all_lines = ''
264 for line in line_list: 276 for line in line_list:
265 end_bracket_index = line.split().index(']') 277 end_bracket_index = line.split().index(']')
266 test_name = line.split()[end_bracket_index + 1] 278 test_name = line.split()[end_bracket_index + 1]
267 if test_name in file_contents: 279 if test_name in file_contents:
(...skipping 20 matching lines...) Expand all
288 Args: 300 Args:
289 tests_results: A dict mapping test name to platform to test results. 301 tests_results: A dict mapping test name to platform to test results.
290 302
291 Returns: 303 Returns:
292 An updated tests_results dictionary without the platform-specific 304 An updated tests_results dictionary without the platform-specific
293 testharness.js tests that required new baselines to be downloaded 305 testharness.js tests that required new baselines to be downloaded
294 from `webkit-patch rebaseline-from-try-jobs`. 306 from `webkit-patch rebaseline-from-try-jobs`.
295 """ 307 """
296 modified_files = self.host.executive.run_command(['git', 'diff', 'origin /master', '--name-only']).splitlines() 308 modified_files = self.host.executive.run_command(['git', 'diff', 'origin /master', '--name-only']).splitlines()
297 tests_to_rebaseline, tests_results = self.get_tests_to_rebaseline(modifi ed_files, tests_results) 309 tests_to_rebaseline, tests_results = self.get_tests_to_rebaseline(modifi ed_files, tests_results)
310 _log.debug('Tests to rebaseline: %r', tests_to_rebaseline)
298 if tests_to_rebaseline: 311 if tests_to_rebaseline:
299 webkit_patch = self.host.filesystem.join( 312 webkit_patch = self.host.filesystem.join(
300 self.finder.chromium_base(), self.finder.webkit_base(), self.fin der.path_to_script('webkit-patch')) 313 self.finder.chromium_base(), self.finder.webkit_base(), self.fin der.path_to_script('webkit-patch'))
301 self.host.executive.run_command([ 314 self.host.executive.run_command([
302 'python', 315 'python',
303 webkit_patch, 316 webkit_patch,
304 'rebaseline-cl', 317 'rebaseline-cl',
305 '--verbose', 318 '--verbose',
306 '--no-trigger-jobs', 319 '--no-trigger-jobs',
307 '--only-changed-tests', 320 '--only-changed-tests',
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 356
344 Args: 357 Args:
345 test_path: A file path relative to the layout tests directory. 358 test_path: A file path relative to the layout tests directory.
346 This might correspond to a deleted file or a non-test. 359 This might correspond to a deleted file or a non-test.
347 """ 360 """
348 absolute_path = self.host.filesystem.join(self.finder.layout_tests_dir() , test_path) 361 absolute_path = self.host.filesystem.join(self.finder.layout_tests_dir() , test_path)
349 test_parser = TestParser(absolute_path, self.host) 362 test_parser = TestParser(absolute_path, self.host)
350 if not test_parser.test_doc: 363 if not test_parser.test_doc:
351 return False 364 return False
352 return test_parser.is_jstest() 365 return test_parser.is_jstest()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698