Skip to content
Permalink
Browse files
webkit-patch rebaseline-expectations command should not rearrange the…
… entire test_expectations.txt file.

https://bugs.webkit.org/show_bug.cgi?id=66727

Reviewed by Adam Barth.

* Scripts/webkitpy/layout_tests/models/test_expectations.py: Made it possible to run TestExpectationSerializer without a TestConfigurationConverter,
    in which case the serializer treats all expectations as unparsed.
* Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py: Added unit tests.


Canonical link: https://commits.webkit.org/82541@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@93562 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
dglazkov committed Aug 22, 2011
1 parent 1938757 commit c4739cdc09350f7fc189bbc75bab4f9e075f2b07
Showing 3 changed files with 36 additions and 15 deletions.
@@ -1,3 +1,14 @@
2011-08-22 Dimitri Glazkov <dglazkov@chromium.org>

webkit-patch rebaseline-expectations command should not rearrange the entire test_expectations.txt file.
https://bugs.webkit.org/show_bug.cgi?id=66727

Reviewed by Adam Barth.

* Scripts/webkitpy/layout_tests/models/test_expectations.py: Made it possible to run TestExpectationSerializer without a TestConfigurationConverter,
in which case the serializer treats all expectations as unparsed.
* Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py: Added unit tests.

2011-08-22 Dimitri Glazkov <dglazkov@chromium.org>

Update unit test expectations after r93530.
@@ -121,7 +121,7 @@ def __repr__(self):

class TestExpectationSerializer(object):
"""Provides means of serializing TestExpectationLine instances."""
def __init__(self, test_configuration_converter):
def __init__(self, test_configuration_converter=None):
self._test_configuration_converter = test_configuration_converter
self._parsed_expectation_to_string = dict([[parsed_expectation, expectation_string] for expectation_string, parsed_expectation in TestExpectations.EXPECTATIONS.items()])

@@ -132,7 +132,7 @@ def to_string(self, expectation_line):
if expectation_line.name is None:
return '' if expectation_line.comment is None else "//%s" % expectation_line.comment

if expectation_line.parsed_bug_modifiers:
if self._test_configuration_converter and expectation_line.parsed_bug_modifiers:
specifiers_list = self._test_configuration_converter.to_specifiers_list(expectation_line.matching_configurations)
result = []
for specifiers in specifiers_list:
@@ -151,6 +151,7 @@ def _parsed_expectations_string(self, expectation_line):
return ' '.join(result)

def _parsed_modifier_string(self, expectation_line, specifiers):
assert(self._test_configuration_converter)
result = []
if expectation_line.parsed_bug_modifiers:
result.extend(sorted(expectation_line.parsed_bug_modifiers))
@@ -166,7 +167,7 @@ def _format_result(cls, modifiers, name, expectations, comment):
return result

@classmethod
def list_to_string(cls, expectation_lines, test_configuration_converter, reconstitute_only_these=None):
def list_to_string(cls, expectation_lines, test_configuration_converter=None, reconstitute_only_these=None):
serializer = cls(test_configuration_converter)

def serialize(expectation_line):
@@ -930,12 +931,12 @@ def _process_tests_without_expectations(self):
def has_warnings(self):
return self._has_warnings

def remove_rebaselined_tests(self, tests):
def remove_rebaselined_tests(self, except_these_tests):
"""Returns a copy of the expectations with the tests removed."""
def without_rebaseline_modifier(expectation):
return not (not expectation.is_malformed() and expectation.name in tests and "rebaseline" in expectation.modifiers)
return not (not expectation.is_malformed() and expectation.name in except_these_tests and "rebaseline" in expectation.modifiers)

return TestExpectationSerializer.list_to_string(filter(without_rebaseline_modifier, self._expectations), self._test_configuration_converter)
return TestExpectationSerializer.list_to_string(filter(without_rebaseline_modifier, self._expectations))

def _add_expectations(self, expectation_list, overrides_allowed):
for expectation_line in expectation_list:
@@ -482,24 +482,33 @@ def assert_list_round_trip(self, in_string, expected_string=None):

def test_unparsed_to_string(self):
expectation = TestExpectationLine()
serializer = TestExpectationSerializer()

self.assertEqual(self._serializer.to_string(expectation), '')
self.assertEqual(serializer.to_string(expectation), '')
expectation.comment = 'Qux.'
self.assertEqual(self._serializer.to_string(expectation), '//Qux.')
self.assertEqual(serializer.to_string(expectation), '//Qux.')
expectation.name = 'bar'
self.assertEqual(self._serializer.to_string(expectation), ' : bar = //Qux.')
self.assertEqual(serializer.to_string(expectation), ' : bar = //Qux.')
expectation.modifiers = ['foo']
self.assertEqual(self._serializer.to_string(expectation), 'FOO : bar = //Qux.')
self.assertEqual(serializer.to_string(expectation), 'FOO : bar = //Qux.')
expectation.expectations = ['bAz']
self.assertEqual(self._serializer.to_string(expectation), 'FOO : bar = BAZ //Qux.')
self.assertEqual(serializer.to_string(expectation), 'FOO : bar = BAZ //Qux.')
expectation.expectations = ['bAz1', 'baZ2']
self.assertEqual(self._serializer.to_string(expectation), 'FOO : bar = BAZ1 BAZ2 //Qux.')
self.assertEqual(serializer.to_string(expectation), 'FOO : bar = BAZ1 BAZ2 //Qux.')
expectation.modifiers = ['foo1', 'foO2']
self.assertEqual(self._serializer.to_string(expectation), 'FOO1 FOO2 : bar = BAZ1 BAZ2 //Qux.')
self.assertEqual(serializer.to_string(expectation), 'FOO1 FOO2 : bar = BAZ1 BAZ2 //Qux.')
expectation.errors.append('Oh the horror.')
self.assertEqual(self._serializer.to_string(expectation), '')
self.assertEqual(serializer.to_string(expectation), '')
expectation.original_string = 'Yes it is!'
self.assertEqual(self._serializer.to_string(expectation), 'Yes it is!')
self.assertEqual(serializer.to_string(expectation), 'Yes it is!')

def test_unparsed_list_to_string(self):
expectation = TestExpectationLine()
expectation.comment = 'Qux.'
expectation.name = 'bar'
expectation.modifiers = ['foo']
expectation.expectations = ['bAz1', 'baZ2']
self.assertEqual(TestExpectationSerializer.list_to_string([expectation]), 'FOO : bar = BAZ1 BAZ2 //Qux.')

def test_parsed_to_string(self):
expectation_line = TestExpectationLine()

0 comments on commit c4739cd

Please sign in to comment.