Title: [120240] trunk/Tools
Revision
120240
Author
[email protected]
Date
2012-06-13 13:14:41 -0700 (Wed, 13 Jun 2012)

Log Message

webkitpy: update callers to use port.expectation_dict() instead of test_expectations() and test_expectations_overrides()
https://bugs.webkit.org/show_bug.cgi?id=88946

Reviewed by Ojan Vafai.

In preparation for fully supporting cascading expectations files
and removing the 'overrides' concept.

There should be no functional changes in this patch.

* Scripts/webkitpy/layout_tests/controllers/manager_unittest.py:
(ManagerTest.test_update_summary_with_result):
(ResultSummaryTest.get_result_summary):
* Scripts/webkitpy/layout_tests/models/test_expectations.py:
(TestExpectations.__init__):
* Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py:
(parse_exp):
(SkippedTests.check):
(RemoveConfigurationsTest.test_remove):
(test_remove_line):
* Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
(LintTest.test_all_configurations.FakePort.__init__):
(LintTest.test_all_configurations.FakePort.expectations_dict):
(LintTest.test_lint_test_files__errors):
* Scripts/webkitpy/tool/commands/rebaseline_unittest.py:
(test_overrides_are_included_correctly):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (120239 => 120240)


--- trunk/Tools/ChangeLog	2012-06-13 20:04:10 UTC (rev 120239)
+++ trunk/Tools/ChangeLog	2012-06-13 20:14:41 UTC (rev 120240)
@@ -1,5 +1,34 @@
 2012-06-13  Dirk Pranke  <[email protected]>
 
+        webkitpy: update callers to use port.expectation_dict() instead of test_expectations() and test_expectations_overrides()
+        https://bugs.webkit.org/show_bug.cgi?id=88946
+
+        Reviewed by Ojan Vafai.
+
+        In preparation for fully supporting cascading expectations files
+        and removing the 'overrides' concept.
+
+        There should be no functional changes in this patch.
+
+        * Scripts/webkitpy/layout_tests/controllers/manager_unittest.py:
+        (ManagerTest.test_update_summary_with_result):
+        (ResultSummaryTest.get_result_summary):
+        * Scripts/webkitpy/layout_tests/models/test_expectations.py:
+        (TestExpectations.__init__):
+        * Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py:
+        (parse_exp):
+        (SkippedTests.check):
+        (RemoveConfigurationsTest.test_remove):
+        (test_remove_line):
+        * Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py:
+        (LintTest.test_all_configurations.FakePort.__init__):
+        (LintTest.test_all_configurations.FakePort.expectations_dict):
+        (LintTest.test_lint_test_files__errors):
+        * Scripts/webkitpy/tool/commands/rebaseline_unittest.py:
+        (test_overrides_are_included_correctly):
+
+2012-06-13  Dirk Pranke  <[email protected]>
+
         webkitpy: rework the TestExpectations style checker in preparation for the cascade
         https://bugs.webkit.org/show_bug.cgi?id=88945
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py (120239 => 120240)


--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py	2012-06-13 20:04:10 UTC (rev 120239)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/manager_unittest.py	2012-06-13 20:14:41 UTC (rev 120240)
@@ -280,7 +280,7 @@
         host = MockHost()
         port = host.port_factory.get('test-win-xp')
         test = 'failures/expected/reftest.html'
-        port.test_expectations = lambda: 'WONTFIX : failures/expected/reftest.html = IMAGE'
+        port.expectations_dict = lambda: {'': 'WONTFIX : failures/expected/reftest.html = IMAGE'}
         expectations = TestExpectations(port, tests=[test])
         # Reftests expected to be image mismatch should be respected when pixel_tests=False.
         manager = Manager(port=port, options=MockOptions(pixel_tests=False, exit_after_n_failures=None, exit_after_n_crashes_or_timeouts=None), printer=Mock())
@@ -422,7 +422,7 @@
         return test_results.TestResult(test_name, failures=failures, test_run_time=run_time)
 
     def get_result_summary(self, port, test_names, expectations_str):
-        port.test_expectations = lambda: expectations_str
+        port.expectations_dict = lambda: {'': expectations_str}
         expectations = test_expectations.TestExpectations(port, test_names)
         return test_names, result_summary.ResultSummary(expectations, test_names), expectations
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py (120239 => 120240)


--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2012-06-13 20:04:10 UTC (rev 120239)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2012-06-13 20:14:41 UTC (rev 120240)
@@ -758,11 +758,12 @@
         self._port = port
         self._skipped_tests_warnings = []
 
-        self._expectations = self._parser.parse(port.path_to_test_expectations_file(), port.test_expectations())
+        expectations_dict = port.expectations_dict()
+        self._expectations = self._parser.parse(expectations_dict.keys()[0], expectations_dict.values()[0])
         self._add_expectations(self._expectations, in_overrides=False)
 
-        overrides = port.test_expectations_overrides()
-        if overrides and include_overrides:
+        if len(expectations_dict) > 1 and include_overrides:
+            overrides = ''.join(expectations_dict.values()[1:])
             overrides_expectations = self._parser.parse('overrides', overrides)
             self._add_expectations(overrides_expectations, in_overrides=True)
             self._expectations += overrides_expectations

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py (120239 => 120240)


--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py	2012-06-13 20:04:10 UTC (rev 120239)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations_unittest.py	2012-06-13 20:14:41 UTC (rev 120240)
@@ -35,7 +35,13 @@
 from webkitpy.layout_tests.models.test_expectations import *
 from webkitpy.layout_tests.models.test_configuration import *
 
+try:
+    from collections import OrderedDict
+except ImportError:
+    # Needed for Python < 2.7
+    from webkitpy.thirdparty.ordered_dict import OrderedDict
 
+
 class MockBugManager(object):
     def close_bug(self, bug_id, reference_bug_id=None):
         pass
@@ -128,8 +134,11 @@
 """
 
     def parse_exp(self, expectations, overrides=None, is_lint_mode=False):
-        self._port.test_expectations = lambda: expectations
-        self._port.test_expectations_overrides = lambda: overrides
+        self._expectations_dict = OrderedDict()
+        self._expectations_dict['expectations'] = expectations
+        if overrides:
+            self._expectations_dict['overrides'] = overrides
+        self._port.expectations_dict = lambda: self._expectations_dict
         self._exp = TestExpectations(self._port, self.get_basic_tests(), is_lint_mode)
 
     def assert_exp(self, test, result):
@@ -206,17 +215,17 @@
 SKIP : failures/expected/image.html""", is_lint_mode=True)
             self.assertFalse(True, "ParseError wasn't raised")
         except ParseError, e:
-            warnings = [u":1 Test lacks BUG modifier. failures/expected/text.html",
-                        u":1 Unrecognized modifier 'foo' failures/expected/text.html",
-                        u":2 Missing expectations SKIP : failures/expected/image.html"]
-            self.assertEqual(str(e), '\n'.join(self._port.path_to_test_expectations_file() + str(warning) for warning in warnings))
+            warnings = ("expectations:1 Test lacks BUG modifier. failures/expected/text.html\n"
+                        "expectations:1 Unrecognized modifier 'foo' failures/expected/text.html\n"
+                        "expectations:2 Missing expectations SKIP : failures/expected/image.html")
+            self.assertEqual(str(e), warnings)
 
         try:
             self.parse_exp('SKIP : failures/expected/text.html = TEXT', is_lint_mode=True)
             self.assertFalse(True, "ParseError wasn't raised")
         except ParseError, e:
-            warnings = [u':1 Test lacks BUG modifier. failures/expected/text.html']
-            self.assertEqual(str(e), '\n'.join(self._port.path_to_test_expectations_file() + str(warning) for warning in warnings))
+            warnings = u'expectations:1 Test lacks BUG modifier. failures/expected/text.html'
+            self.assertEqual(str(e), warnings)
 
     def test_error_on_different_platform(self):
         # parse_exp uses a Windows port. Assert errors on Mac show up in lint mode.
@@ -270,8 +279,11 @@
     def check(self, expectations, overrides, skips, lint=False):
         port = MockHost().port_factory.get('qt')
         port._filesystem.write_text_file(port._filesystem.join(port.layout_tests_dir(), 'failures/expected/text.html'), 'foo')
-        port.test_expectations = lambda: expectations
-        port.test_expectations_overrides = lambda: overrides
+        self._expectations_dict = OrderedDict()
+        self._expectations_dict['expectations'] = expectations
+        if overrides:
+            self._expectations_dict['overrides'] = overrides
+        port.expectations_dict = lambda: self._expectations_dict
         port.skipped_layout_tests = lambda tests: set(skips)
         exp = TestExpectations(port, ['failures/expected/text.html'], lint)
 
@@ -416,9 +428,9 @@
         test_port.test_isfile = lambda test: True
 
         test_config = test_port.test_configuration()
-        test_port.test_expectations = lambda: """BUGX LINUX WIN RELEASE : failures/expected/foo.html = TEXT
+        test_port.expectations_dict = lambda: {"expectations": """BUGX LINUX WIN RELEASE : failures/expected/foo.html = TEXT
 BUGY WIN MAC DEBUG : failures/expected/foo.html = CRASH
-"""
+"""}
         expectations = TestExpectations(test_port, self.get_basic_tests())
 
         actual_expectations = expectations.remove_configuration_from_test('failures/expected/foo.html', test_config)
@@ -434,9 +446,9 @@
         test_port.test_isfile = lambda test: True
 
         test_config = test_port.test_configuration()
-        test_port.test_expectations = lambda: """BUGX WIN RELEASE : failures/expected/foo.html = TEXT
+        test_port.expectations_dict = lambda: {'expectations': """BUGX WIN RELEASE : failures/expected/foo.html = TEXT
 BUGY WIN DEBUG : failures/expected/foo.html = CRASH
-"""
+"""}
         expectations = TestExpectations(test_port)
 
         actual_expectations = expectations.remove_configuration_from_test('failures/expected/foo.html', test_config)

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py (120239 => 120240)


--- trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py	2012-06-13 20:04:10 UTC (rev 120239)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/run_webkit_tests_integrationtest.py	2012-06-13 20:14:41 UTC (rev 120240)
@@ -197,18 +197,15 @@
                 self.name = name
                 self.path = path
 
-            def test_expectations(self):
-                self.host.ports_parsed.append(self.name)
-                return ''
-
             def path_to_test_expectations_file(self):
                 return self.path
 
             def test_configuration(self):
                 return None
 
-            def test_expectations_overrides(self):
-                return None
+            def expectations_dict(self):
+                self.host.ports_parsed.append(self.name)
+                return {self.path: ''}
 
             def skipped_layout_tests(self, tests):
                 return set([])
@@ -261,7 +258,7 @@
         options, parsed_args = parse_args(['--lint-test-files'])
         host = MockHost()
         port_obj = host.port_factory.get(options.platform, options=options)
-        port_obj.test_expectations = lambda: "# syntax error"
+        port_obj.expectations_dict = lambda: {'': '# syntax error'}
         res, out, err = run_and_capture(port_obj, options, parsed_args)
 
         self.assertEqual(res, -1)

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py (120239 => 120240)


--- trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py	2012-06-13 20:04:10 UTC (rev 120239)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/rebaseline_unittest.py	2012-06-13 20:14:41 UTC (rev 120240)
@@ -254,12 +254,16 @@
 
         # This tests that the any tests marked as REBASELINE in the overrides are found, but
         # that the overrides do not get written into the main file.
-        self.overrides = ('BUGX REBASELINE : userscripts/another-test.html = TEXT\n'
-                          'BUGY : userscripts/test.html = CRASH\n')
+        expectations_path = port.expectations_files()[0]
+        expectations_contents = ''
+        port._filesystem.write_text_file(expectations_path, expectations_contents)
+        port.expectations_dict = lambda: {
+            expectations_path: expectations_contents,
+            'overrides': ('BUGX REBASELINE : userscripts/another-test.html = TEXT\n'
+                          'BUGY : userscripts/test.html = CRASH\n')}
 
         for path in port.expectations_files():
             port._filesystem.write_text_file(path, '')
         port._filesystem.write_text_file(port.layout_tests_dir() + '/userscripts/another-test.html', '')
-        port.test_expectations_overrides = lambda: self.overrides
         self.assertEquals(command._tests_to_rebaseline(port), {'userscripts/another-test.html': set(['txt'])})
-        self.assertEquals(port._filesystem.read_text_file(port.path_to_test_expectations_file()), '')
+        self.assertEquals(port._filesystem.read_text_file(expectations_path), expectations_contents)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to