Commit 0f77323c authored by qyearsley's avatar qyearsley Committed by Commit bot

In update-w3c-test-expectations, handle failure to fetch results.

Specifically, when no layout tests are fetched for a particular build,
log a warning and continue instead of raising an exception and aborting.

I noticed this error when running the script on my workstation.

This CL also adds several TODO notes.

BUG=629275

Review-Url: https://codereview.chromium.org/2277303003
Cr-Commit-Position: refs/heads/master@{#414497}
parent ae706b00
...@@ -31,6 +31,9 @@ from webkitpy.common.net.layouttestresults import LayoutTestResults ...@@ -31,6 +31,9 @@ from webkitpy.common.net.layouttestresults import LayoutTestResults
from webkitpy.common.net.layouttestresults_unittest import LayoutTestResultsTest from webkitpy.common.net.layouttestresults_unittest import LayoutTestResultsTest
# TODO(qyearsley): Instead of canned results from another module, other unit
# tests may be a little easier to understand if this returned None by default
# when there are no canned results to return.
class MockBuildBot(BuildBot): class MockBuildBot(BuildBot):
def __init__(self): def __init__(self):
......
...@@ -51,9 +51,16 @@ class LayoutTestResult(object): ...@@ -51,9 +51,16 @@ class LayoutTestResult(object):
return 'PASS' in self.actual_results() return 'PASS' in self.actual_results()
def did_run_as_expected(self): def did_run_as_expected(self):
# TODO(qyearsley): For correctness, this should be:
# return not self._result_dict.get('is_unexpected', False)
# (Right now for expected results it's not added to the result dict
# but in theory it could be present.)
return 'is_unexpected' not in self._result_dict return 'is_unexpected' not in self._result_dict
def is_missing_image(self): def is_missing_image(self):
# TODO(qyearsley): Change this to:
# self._result_dict.get('is_missing_image', False)
# The following method should likewise be changed.
return 'is_missing_image' in self._result_dict return 'is_missing_image' in self._result_dict
def is_missing_text(self): def is_missing_text(self):
......
...@@ -8,14 +8,20 @@ based on layout test failures in try jobs. ...@@ -8,14 +8,20 @@ based on layout test failures in try jobs.
This script is used as part of the w3c test auto-import process. This script is used as part of the w3c test auto-import process.
""" """
import logging
from webkitpy.common.net.rietveld import Rietveld from webkitpy.common.net.rietveld import Rietveld
from webkitpy.common.net.buildbot import BuildBot from webkitpy.common.net.buildbot import BuildBot, Build
from webkitpy.common.net.git_cl import GitCL from webkitpy.common.net.git_cl import GitCL
from webkitpy.common.webkit_finder import WebKitFinder from webkitpy.common.webkit_finder import WebKitFinder
from webkitpy.w3c.test_parser import TestParser from webkitpy.w3c.test_parser import TestParser
_log = logging.getLogger(__name__)
def main(host): def main(host):
# TODO(qyearsley): Add a "main" function to W3CExpectationsLineAdder
# and move most or all of this logic in there.
host.initialize_scm() host.initialize_scm()
port = host.port_factory.get() port = host.port_factory.get()
expectations_file = port.path_to_generic_test_expectations_file() expectations_file = port.path_to_generic_test_expectations_file()
...@@ -72,7 +78,11 @@ class W3CExpectationsLineAdder(object): ...@@ -72,7 +78,11 @@ class W3CExpectationsLineAdder(object):
Collects the builder name, platform and a list of tests that did not Collects the builder name, platform and a list of tests that did not
run as expected. run as expected.
TODO(qyearsley): Rather than taking a BuildBot object, this should use
the Host's BuildBot object.
Args: Args:
buildbot: A BuildBot object.
builder: A Builder object. builder: A Builder object.
build: A Build object. build: A Build object.
...@@ -84,9 +94,13 @@ class W3CExpectationsLineAdder(object): ...@@ -84,9 +94,13 @@ class W3CExpectationsLineAdder(object):
'bug': 'crbug.com/11111' 'bug': 'crbug.com/11111'
} }
} }
If there are no failing results or no results could be fetched,
this will return an empty dict.
""" """
results_url = buildbot.results_url(builder_name, build_number) layout_test_results = buildbot.fetch_results(Build(builder_name, build_number))
layout_test_results = buildbot.fetch_layout_test_results(results_url) if layout_test_results is None:
_log.warning('No results for builder %s, build %s', builder_name, build_number)
return {}
platform = self._host.builders.port_name_for_builder_name(builder_name) platform = self._host.builders.port_name_for_builder_name(builder_name)
result_list = layout_test_results.didnt_run_as_expected_results() result_list = layout_test_results.didnt_run_as_expected_results()
failing_results_dict = self._generate_results_dict(platform, result_list) failing_results_dict = self._generate_results_dict(platform, result_list)
......
...@@ -5,8 +5,11 @@ ...@@ -5,8 +5,11 @@
import unittest import unittest
from webkitpy.common.host_mock import MockHost 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.webkit_finder import WebKitFinder
from webkitpy.common.net.layouttestresults import LayoutTestResult from webkitpy.layout_tests.builder_list import BuilderList
from webkitpy.w3c.update_w3c_test_expectations import W3CExpectationsLineAdder from webkitpy.w3c.update_w3c_test_expectations import W3CExpectationsLineAdder
...@@ -36,6 +39,59 @@ class UpdateW3CTestExpectationsTest(unittest.TestCase, W3CExpectationsLineAdder) ...@@ -36,6 +39,59 @@ class UpdateW3CTestExpectationsTest(unittest.TestCase, W3CExpectationsLineAdder)
'one': {'expected': 'FAIL', 'actual': 'TIMEOUT', 'bug': 'crbug.com/626703'} 'one': {'expected': 'FAIL', 'actual': 'TIMEOUT', 'bug': 'crbug.com/626703'}
} }
} }
self.host.builders = BuilderList({
'mac': {'port_name': 'test-mac'},
})
def tearDown(self):
self.host = None
def test_get_failing_results_dict_only_passing_results(self):
self.host.buildbot.set_results(Build('mac', 123), LayoutTestResults({
'tests': {
'fake': {
'test.html': {
'passing-test.html': {
'expected': 'PASS',
'actual': 'PASS',
},
},
},
},
}))
line_adder = W3CExpectationsLineAdder(self.host)
self.assertEqual(line_adder.get_failing_results_dict(self.host.buildbot, 'mac', 123), {})
def test_get_failing_results_dict_no_results(self):
self.host.buildbot = MockBuildBot()
self.host.buildbot.set_results(Build('mac', 123), None)
line_adder = W3CExpectationsLineAdder(self.host)
self.assertEqual(line_adder.get_failing_results_dict(self.host.buildbot, 'mac', 123), {})
def test_get_failing_results_dict_some_failing_results(self):
self.host.buildbot.set_results(Build('mac', 123), LayoutTestResults({
'tests': {
'fake': {
'test.html': {
'failing-test.html': {
'expected': 'PASS',
'actual': 'IMAGE',
'is_unexpected': True,
},
},
},
},
}))
line_adder = W3CExpectationsLineAdder(self.host)
self.assertEqual(line_adder.get_failing_results_dict(self.host.buildbot, 'mac', 123), {
'fake/test.html/failing-test.html': {
'Mac': {
'actual': 'IMAGE',
'expected': 'PASS',
'bug': 'crbug.com/626703',
},
},
})
def test_merge_same_valued_keys(self): def test_merge_same_valued_keys(self):
self.assertEqual( self.assertEqual(
......
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