Title: [106038] trunk/Tools
Revision
106038
Author
o...@chromium.org
Date
2012-01-26 13:46:36 -0800 (Thu, 26 Jan 2012)

Log Message

Parsing test_expecations.txt + Skipped lists takes too long
https://bugs.webkit.org/show_bug.cgi?id=77059

Reviewed by Dirk Pranke.

This saves ~100ms on the Apple Mac port.
-memoize a bunch of path methods.
-Avoid doing multiple disk accesses per line.
-Parse the skipped list directly instead of turning it into a test_expecations.txt
formatting string and parsing that.

* Scripts/webkitpy/layout_tests/models/test_expectations.py:
(TestExpectationParser):
(TestExpectationParser.parse_skipped_tests):
(TestExpectationParser._parse_line):
(TestExpectationParser._collect_matching_tests):
(TestExpectations.__init__):
(TestExpectations._add_skipped_tests):
* Scripts/webkitpy/layout_tests/port/base.py:
(Port):
(Port.test_isfile):
(Port.normalize_test_name):
(Port.layout_tests_dir):
(Port.abspath_for_test):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (106037 => 106038)


--- trunk/Tools/ChangeLog	2012-01-26 21:38:19 UTC (rev 106037)
+++ trunk/Tools/ChangeLog	2012-01-26 21:46:36 UTC (rev 106038)
@@ -1,5 +1,32 @@
 2012-01-25  Ojan Vafai  <o...@chromium.org>
 
+        Parsing test_expecations.txt + Skipped lists takes too long
+        https://bugs.webkit.org/show_bug.cgi?id=77059
+
+        Reviewed by Dirk Pranke.
+
+        This saves ~100ms on the Apple Mac port.
+        -memoize a bunch of path methods.
+        -Avoid doing multiple disk accesses per line.
+        -Parse the skipped list directly instead of turning it into a test_expecations.txt
+        formatting string and parsing that.
+
+        * Scripts/webkitpy/layout_tests/models/test_expectations.py:
+        (TestExpectationParser):
+        (TestExpectationParser.parse_skipped_tests):
+        (TestExpectationParser._parse_line):
+        (TestExpectationParser._collect_matching_tests):
+        (TestExpectations.__init__):
+        (TestExpectations._add_skipped_tests):
+        * Scripts/webkitpy/layout_tests/port/base.py:
+        (Port):
+        (Port.test_isfile):
+        (Port.normalize_test_name):
+        (Port.layout_tests_dir):
+        (Port.abspath_for_test):
+
+2012-01-25  Ojan Vafai  <o...@chromium.org>
+
         Only store the SVN revision in the summarized results if we're on a builder
         https://bugs.webkit.org/show_bug.cgi?id=76976
 

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


--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2012-01-26 21:38:19 UTC (rev 106037)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py	2012-01-26 21:46:36 UTC (rev 106038)
@@ -187,6 +187,7 @@
     BUG_MODIFIER_PREFIX = 'bug'
     BUG_MODIFIER_REGEX = 'bug\d+'
     REBASELINE_MODIFIER = 'rebaseline'
+    FAIL_EXPECTATION = 'fail'
     SKIP_MODIFIER = 'skip'
     SLOW_MODIFIER = 'slow'
     WONTFIX_MODIFIER = 'wontfix'
@@ -205,15 +206,30 @@
             self._parse_line(expectation_line)
         return expectations
 
+    def expectation_for_skipped_test(self, test_name):
+        expectation_line = TestExpectationLine()
+        expectation_line.original_string = test_name
+        expectation_line.modifiers = [TestExpectationParser.SKIP_MODIFIER]
+        expectation_line.name = test_name
+        expectation_line.expectations = [TestExpectationParser.FAIL_EXPECTATION]
+        self._parse_line(expectation_line)
+        return expectation_line
+
     def _parse_line(self, expectation_line):
         if not expectation_line.name:
             return
 
         self._check_modifiers_against_expectations(expectation_line)
-        if self._check_path_does_not_exist(expectation_line):
+
+        expectation_line.is_file = self._port.test_isfile(expectation_line.name)
+        if not expectation_line.is_file and self._check_path_does_not_exist(expectation_line):
             return
 
-        expectation_line.path = self._port.normalize_test_name(expectation_line.name)
+        if expectation_line.is_file:
+            expectation_line.path = expectation_line.name
+        else:
+            expectation_line.path = self._port.normalize_test_name(expectation_line.name)
+
         self._collect_matching_tests(expectation_line)
 
         self._parse_modifiers(expectation_line)
@@ -285,7 +301,7 @@
             expectation_line.matching_tests = [expectation_line.path]
             return
 
-        if self._port.test_isdir(expectation_line.path):
+        if not expectation_line.is_file:
             # this is a test category, return all the tests of the category.
             expectation_line.matching_tests = [test for test in self._full_test_list if test.startswith(expectation_line.path)]
             return
@@ -702,7 +718,6 @@
         self._model = TestExpectationsModel()
         self._parser = TestExpectationParser(port, tests, is_lint_mode)
         self._port = port
-        self._test_configuration_converter = TestConfigurationConverter(port.all_test_configurations(), port.configuration_specifier_macros())
         self._skipped_tests_warnings = []
 
         self._expectations = self._parser.parse(expectations)
@@ -835,6 +850,5 @@
         for index, test in enumerate(self._expectations, start=1):
             if test.name and test.name in tests_to_skip:
                 self._skipped_tests_warnings.append(':%d %s is also in a Skipped file.' % (index, test.name))
-        skipped_tests = '\n'.join(map(lambda test_path: 'BUG_SKIPPED SKIP : %s = FAIL' % test_path, tests_to_skip))
-        for test in self._parser.parse(skipped_tests):
-            self._model.add_expectation_line(test, overrides_allowed=True)
+        for test_name in tests_to_skip:
+            self._model.add_expectation_line(self._parser.expectation_for_skipped_test(test_name), overrides_allowed=True)

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py (106037 => 106038)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py	2012-01-26 21:38:19 UTC (rev 106037)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py	2012-01-26 21:46:36 UTC (rev 106038)
@@ -518,6 +518,14 @@
         return filter(lambda x: self._filesystem.isdir(self._filesystem.join(layout_tests_dir, x)),
                       self._filesystem.listdir(layout_tests_dir))
 
+    @memoized
+    def test_isfile(self, test_name):
+        """Return True if the test name refers to a directory of tests."""
+        # Used by test_expectations.py to apply rules to whole directories.
+        test_path = self.abspath_for_test(test_name)
+        return self._filesystem.isfile(test_path)
+
+    @memoized
     def test_isdir(self, test_name):
         """Return True if the test name refers to a directory of tests."""
         # Used by test_expectations.py to apply rules to whole directories.
@@ -540,7 +548,9 @@
 
     def normalize_test_name(self, test_name):
         """Returns a normalized version of the test name or test directory."""
-        if self.test_isdir(test_name) and not test_name.endswith('/'):
+        if test_name.endswith('/'):
+            return test_name
+        if self.test_isdir(test_name):
             return test_name + '/'
         return test_name
 
@@ -560,9 +570,10 @@
         """
         self._filesystem.write_binary_file(baseline_path, data)
 
+    @memoized
     def layout_tests_dir(self):
         """Return the absolute path to the top of the LayoutTests directory."""
-        return self.path_from_webkit_base('LayoutTests')
+        return self._filesystem.normpath(self.path_from_webkit_base('LayoutTests'))
 
     def perf_tests_dir(self):
         """Return the absolute path to the top of the PerformanceTests directory."""
@@ -697,10 +708,11 @@
         assert filename.startswith(self.perf_tests_dir()), "%s did not start with %s" % (filename, self.perf_tests_dir())
         return filename[len(self.perf_tests_dir()) + 1:]
 
+    @memoized
     def abspath_for_test(self, test_name):
         """Returns the full path to the file for a given test name. This is the
         inverse of relative_test_filename()."""
-        return self._filesystem.normpath(self._filesystem.join(self.layout_tests_dir(), test_name))
+        return self._filesystem.join(self.layout_tests_dir(), test_name)
 
     def results_directory(self):
         """Absolute path to the place to store the test results (uses --results-directory)."""
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to