Commit d6ca4cfd authored by Ned Nguyen's avatar Ned Nguyen Committed by Commit Bot

Update logic to merge platforms in wpt_expectations_updater

This updates wpt_expectations_updater to merge specifiers of same
platform type to a simpler specifier when possible, but still keep separate
expectation lines for different specifiers.

This is needed for later CLs which will update Layout test expectation formats
to no longer have mutual exclusive specifiers on the same expectation line
(CL https://chromium-review.googlesource.com/c/chromium/src/+/1336439)

Bug: 807751
Change-Id: Icd47c6d5d3f35a789ed266ee20fbb60dca382ac3
Reviewed-on: https://chromium-review.googlesource.com/c/1336912
Commit-Queue: Ned Nguyen <nednguyen@google.com>
Reviewed-by: default avatarRobert Ma <robertma@chromium.org>
Reviewed-by: default avatarNed Nguyen <nednguyen@google.com>
Cr-Commit-Position: refs/heads/master@{#610174}
parent 46440956
......@@ -94,7 +94,7 @@ class WPTExpectationsUpdater(object):
# At this point, test_expectations looks like: {
# 'test-with-failing-result': {
# ('port-name1', 'port-name2'): SimpleTestResult,
# 'port-name3': SimpleTestResult
# 'port-name3': AnotherSimpleTestResult
# }
# }
......@@ -310,11 +310,11 @@ class WPTExpectationsUpdater(object):
_log.warning('Non-WPT test "%s" unexpectedly passed to create_line_dict.', test_name)
continue
for port_names, result in sorted(port_results.iteritems()):
line_dict[test_name].append(self._create_line(test_name, port_names, result))
line_dict[test_name].extend(self._create_lines(test_name, port_names, result))
return line_dict
def _create_line(self, test_name, port_names, result):
"""Constructs a test expectation line string.
def _create_lines(self, test_name, port_names, result):
"""Constructs test expectation line strings.
Args:
test_name: The test name string.
......@@ -322,8 +322,10 @@ class WPTExpectationsUpdater(object):
result: A SimpleTestResult.
Returns:
A string that contains a line of test expectation.
A list of strings which each is a line of test expectation for given
|test_name|.
"""
lines = []
port_names = self.tuple_or_value_to_list(port_names)
# The set of ports with no results is assumed to have have no
......@@ -337,43 +339,43 @@ class WPTExpectationsUpdater(object):
# also apply to any ports that we weren't able to get results for.
port_names.extend(self.ports_with_no_results)
specifier_part = self.specifier_part(test_name, port_names)
expectations = '[ %s ]' % ' '.join(self.get_expectations(result, test_name))
for specifier in self.normalized_specifiers(test_name, port_names):
line_parts = []
if specifier_part:
line_parts.append(specifier_part)
if specifier:
line_parts.append('[ %s ]' % specifier)
line_parts.append(test_name)
expectations = '[ %s ]' % ' '.join(self.get_expectations(result, test_name))
line_parts.append(expectations)
# Only add the bug link if the expectations do not include WontFix.
if 'WontFix' not in expectations:
line_parts.insert(0, result.bug)
return ' '.join(line_parts)
lines.append(' '.join(line_parts))
return lines
def specifier_part(self, test_name, port_names):
"""Returns the specifier part for a new test expectations line.
def normalized_specifiers(self, test_name, port_names):
"""Converts and simplifies ports into platform specifiers.
Args:
test_name: The test name string.
port_names: A list of full port names that the line should apply to.
Returns:
The specifier part of the new expectation line, e.g. "[ Mac ]".
This will be an empty string if the line should apply to all platforms.
A list of specifier string, e.g. ["Mac", "Win"].
[''] will be returned if the line should apply to all platforms.
"""
specifiers = []
for name in sorted(port_names):
specifiers.append(self.host.builders.version_specifier_for_port_name(name))
if self.specifiers_can_extend_to_all_platforms(specifiers, test_name):
return ''
return ['']
specifiers = self.simplify_specifiers(specifiers, self.port.configuration_specifier_macros())
if not specifiers:
return ''
return '[ %s ]' % ' '.join(specifiers)
return ['']
return specifiers
@staticmethod
def tuple_or_value_to_list(tuple_or_value):
......
......@@ -349,10 +349,14 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
],
})
def test_specifier_part(self):
def test_normalized_specifiers(self):
updater = WPTExpectationsUpdater(self.mock_host())
self.assertEqual(updater.specifier_part('x/y.html', ['test-mac-mac10.10']), '[ Mac10.10 ]')
self.assertEqual(updater.specifier_part('x/y.html', []), '')
self.assertEqual(updater.normalized_specifiers('x/y.html', ['test-mac-mac10.10']), ['Mac10.10'])
self.assertEqual(updater.normalized_specifiers('x/y.html', []), [''])
self.assertEqual(
updater.normalized_specifiers('x/y.html', ['test-mac-mac10.10', 'test-win-win7']),
['Mac10.10', 'Win7'])
def test_skipped_specifiers_when_test_is_wontfix(self):
host = self.mock_host()
......@@ -404,7 +408,7 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
self.assertEqual(updater.simplify_specifiers(['mac10.10', 'mac10.11'], macros), ['Mac'])
self.assertEqual(updater.simplify_specifiers(['Mac10.10', 'Mac10.11', 'Trusty', 'Win7', 'Win10'], macros), [])
def test_specifier_part_with_skipped_test(self):
def test_normalized_specifiers_with_skipped_test(self):
host = self.mock_host()
expectations_path = '/test.checkout/wtests/NeverFixTests'
host.filesystem.write_text_file(
......@@ -413,11 +417,11 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
host.filesystem.write_text_file('/test.checkout/wtests/external/wpt/test.html', '')
updater = WPTExpectationsUpdater(host)
self.assertEqual(
updater.specifier_part('external/wpt/test.html', ['test-mac-mac10.10', 'test-win-win7', 'test-win-win10']), '')
updater.normalized_specifiers('external/wpt/test.html', ['test-mac-mac10.10', 'test-win-win7', 'test-win-win10']), [''])
self.assertEqual(
updater.specifier_part('external/wpt/test.html', ['test-win-win7', 'test-win-win10']), '[ Win ]')
updater.normalized_specifiers('external/wpt/test.html', ['test-win-win7', 'test-win-win10']), ['Win'])
self.assertEqual(
updater.specifier_part('external/wpt/another.html', ['test-win-win7', 'test-win-win10']), '[ Win ]')
updater.normalized_specifiers('external/wpt/another.html', ['test-win-win7', 'test-win-win10']), ['Win'])
def test_merge_dicts_with_conflict_raise_exception(self):
updater = WPTExpectationsUpdater(self.mock_host())
......@@ -761,5 +765,33 @@ class WPTExpectationsUpdaterTest(LoggingTestCase):
updater.ports_with_no_results = {'test-mac-mac10.10'}
self.assertEqual(
updater.create_line_dict(results),
{'external/wpt/x.html': ['crbug.com/test [ Linux Mac ] external/wpt/x.html [ Failure ]']}
{'external/wpt/x.html': [
'crbug.com/test [ Linux ] external/wpt/x.html [ Failure ]',
'crbug.com/test [ Mac ] external/wpt/x.html [ Failure ]',
]
}
)
def test_merging_platforms_if_possible(self):
host = self.mock_host()
updater = WPTExpectationsUpdater(host)
results = {
'external/wpt/x.html': {
(
'test-linux-precise',
'test-linux-trusty',
'test-mac-mac10.10',
'test-mac-mac10.11',
'test-win-win7',
): SimpleTestResult(expected='PASS', actual='TEXT', bug='crbug.com/test')
}
}
self.assertEqual(
updater.create_line_dict(results),
{'external/wpt/x.html': [
'crbug.com/test [ Linux ] external/wpt/x.html [ Failure ]',
'crbug.com/test [ Mac ] external/wpt/x.html [ Failure ]',
'crbug.com/test [ Win7 ] external/wpt/x.html [ Failure ]',
]
}
)
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