Commit 194e7e00 authored by qyearsley's avatar qyearsley Committed by Commit bot

Add --help and --verbose options to update-w3c-test-expectations.

This CL also adds more logging in update_w3c_test_expectations.py, and changes deps_updater.py to run this script with the --verbose flag.

Purpose of this CL:
 1. Make it easier to diagnose issues with w3c-test-autoroller in the future.
 2. Start to make update-w3c-test-expectations better to use directly.

BUG=643761

Review-Url: https://codereview.chromium.org/2337183002
Cr-Commit-Position: refs/heads/master@{#418718}
parent f62002a0
......@@ -10,4 +10,4 @@ from webkitpy.w3c.update_w3c_test_expectations import W3CExpectationsLineAdder
if __name__ == "__main__":
line_adder = W3CExpectationsLineAdder(host.Host())
sys.exit(line_adder.run())
sys.exit(line_adder.run(sys.argv[1:]))
......@@ -368,7 +368,7 @@ class DepsUpdater(object):
def write_test_expectations(self):
self.print_('## Adding test expectations lines to LayoutTests/TestExpectations.')
script_path = self.path_from_webkit_base('Tools', 'Scripts', 'update-w3c-test-expectations')
self.run([self.host.executable, script_path])
self.run([self.host.executable, script_path, '--verbose'])
message = '\'Modifies TestExpectations and/or downloads new baselines for tests\''
self.check_run(['git', 'commit', '-a', '-m', message])
self.git_cl.run(['upload', '-m', message, '--rietveld'])
......@@ -11,9 +11,9 @@ Specifically, this class fetches results from try bots for the current CL, and:
This is used as part of the w3c test auto-import process.
"""
import argparse
import logging
from webkitpy.common.net.buildbot import BuildBot, Build
from webkitpy.common.net.git_cl import GitCL
from webkitpy.common.net.rietveld import Rietveld
from webkitpy.common.webkit_finder import WebKitFinder
......@@ -29,14 +29,25 @@ class W3CExpectationsLineAdder(object):
self.host.initialize_scm()
self.finder = WebKitFinder(self.host.filesystem)
def run(self):
def run(self, args=None):
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('-v', '--verbose', action='store_true', help='More verbose logging.')
args = parser.parse_args(args)
log_level = logging.DEBUG if args.verbose else logging.INFO
logging.basicConfig(level=log_level, format='%(message)s')
issue_number = self.get_issue_number()
if issue_number == 'None':
_log.error('No issue on current branch.')
return 1
try_bots = self.get_try_bots()
rietveld = Rietveld(self.host.web)
try_jobs = rietveld.latest_try_jobs(issue_number, try_bots)
_log.debug('Latest try jobs: %r', try_jobs)
if not try_jobs:
print 'No Try Job information was collected.'
_log.error('No try job information was collected.')
return 1
test_expectations = {}
......@@ -255,6 +266,7 @@ class W3CExpectationsLineAdder(object):
Args:
line_list: A list of w3c test expectations lines.
"""
_log.debug('Lines to write to TestExpectations: %r', line_list)
port = self.host.port_factory.get()
expectations_file = port.path_to_generic_test_expectations_file()
comment_line = '# Tests added from W3C auto import bot'
......@@ -295,6 +307,7 @@ class W3CExpectationsLineAdder(object):
"""
modified_files = self.host.executive.run_command(['git', 'diff', 'origin/master', '--name-only']).splitlines()
tests_to_rebaseline, tests_results = self.get_tests_to_rebaseline(modified_files, tests_results)
_log.debug('Tests to rebaseline: %r', tests_to_rebaseline)
if tests_to_rebaseline:
webkit_patch = self.host.filesystem.join(
self.finder.chromium_base(), self.finder.webkit_base(), self.finder.path_to_script('webkit-patch'))
......
......@@ -2,20 +2,22 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import unittest
import json
from webkitpy.common.host_mock import MockHost
from webkitpy.common.net.buildbot import Build
from webkitpy.common.net.buildbot_mock import MockBuildBot
from webkitpy.common.net.layouttestresults import LayoutTestResult, LayoutTestResults
from webkitpy.common.webkit_finder import WebKitFinder
from webkitpy.common.net.web_mock import MockWeb
from webkitpy.common.system import logtesting
from webkitpy.layout_tests.builder_list import BuilderList
from webkitpy.w3c.update_w3c_test_expectations import W3CExpectationsLineAdder
class UpdateW3CTestExpectationsTest(unittest.TestCase):
class UpdateW3CTestExpectationsTest(logtesting.LoggingTestCase):
def setUp(self):
super(UpdateW3CTestExpectationsTest, self).setUp()
self.host = MockHost()
self.mock_dict_one = {
'fake/test/path.html': {
......@@ -44,6 +46,7 @@ class UpdateW3CTestExpectationsTest(unittest.TestCase):
})
def tearDown(self):
super(UpdateW3CTestExpectationsTest, self).tearDown()
self.host = None
def test_get_failing_results_dict_only_passing_results(self):
......@@ -224,3 +227,30 @@ class UpdateW3CTestExpectationsTest(unittest.TestCase):
tests_to_rebaseline, tests_results = line_adder.get_tests_to_rebaseline(tests, test_dict)
self.assertEqual(tests_to_rebaseline, ['imported/fake/test/path.html'])
self.assertEqual(tests_results, test_dict)
def test_run_no_issue_number(self):
line_adder = W3CExpectationsLineAdder(self.host)
line_adder.get_issue_number = lambda: 'None'
self.assertEqual(1, line_adder.run(args=[]))
self.assertLog(['ERROR: No issue on current branch.\n'])
def test_run_no_try_results(self):
self.host.web = MockWeb(urls={
'https://codereview.chromium.org/api/11112222': json.dumps({
'patchsets': [1],
}),
'https://codereview.chromium.org/api/11112222/1': json.dumps({
'try_job_results': []
})
})
line_adder = W3CExpectationsLineAdder(self.host)
line_adder.get_issue_number = lambda: '11112222'
line_adder.get_try_bots = lambda: ['test-builder-name']
self.assertEqual(1, line_adder.run(args=[]))
self.assertEqual(
self.host.web.urls_fetched,
[
'https://codereview.chromium.org/api/11112222',
'https://codereview.chromium.org/api/11112222/1'
])
self.assertLog(['ERROR: No try job information was collected.\n'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment