Changeset 205476 in webkit


Ignore:
Timestamp:
Sep 6, 2016 5:30:51 AM (8 years ago)
Author:
commit-queue@webkit.org
Message:

W3C test importer should be able to identify slow test
https://bugs.webkit.org/show_bug.cgi?id=161601

Patch by Youenn Fablet <youenn@apple.com> on 2016-09-06
Reviewed by Darin Adler.

Tools:

Test parser is now identifying slow tests based on "meta element name=timeout content=long" elements.
Test importer is updating test-options.json file according that information.

In case of clean import, the test-options.json is cleaned from 'slow' options for all W3C tests.

  • Scripts/webkitpy/w3c/test_importer.py:

(TestImporter.init):
(TestImporter.find_importable_tests):
(TestImporter.import_tests):
(TestImporter.update_test_options):
(TestImporter):
(TestImporter.remove_slow_from_w3c_test_options):

  • Scripts/webkitpy/w3c/test_parser.py:

(TestParser.analyze_test):
(TestParser.is_slow_test):
(TestParser.potential_ref_filename):

LayoutTests:

  • tests-options.json: Added.
Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r205473 r205476  
     12016-09-06  Youenn Fablet  <youenn@apple.com>
     2
     3        W3C test importer should be able to identify slow test
     4        https://bugs.webkit.org/show_bug.cgi?id=161601
     5
     6        Reviewed by Darin Adler.
     7
     8        * tests-options.json: Added.
     9
    1102016-09-06  Youenn Fablet  <youenn@apple.com>
    211
  • trunk/Tools/ChangeLog

    r205472 r205476  
     12016-09-06  Youenn Fablet  <youenn@apple.com>
     2
     3        W3C test importer should be able to identify slow test
     4        https://bugs.webkit.org/show_bug.cgi?id=161601
     5
     6        Reviewed by Darin Adler.
     7
     8        Test parser is now identifying slow tests based on "meta element name=timeout content=long" elements.
     9        Test importer is updating test-options.json file according that information.
     10
     11        In case of clean import, the test-options.json is cleaned from 'slow' options for all W3C tests.
     12
     13        * Scripts/webkitpy/w3c/test_importer.py:
     14        (TestImporter.__init__):
     15        (TestImporter.find_importable_tests):
     16        (TestImporter.import_tests):
     17        (TestImporter.update_test_options):
     18        (TestImporter):
     19        (TestImporter.remove_slow_from_w3c_test_options):
     20        * Scripts/webkitpy/w3c/test_parser.py:
     21        (TestParser.analyze_test):
     22        (TestParser.is_slow_test):
     23        (TestParser.potential_ref_filename):
     24
    1252016-09-06  Per Arne Vollan  <pvollan@apple.com>
    226
  • trunk/Tools/Scripts/webkitpy/w3c/test_importer.py

    r205453 r205476  
    169169        self.destination_directory = webkit_finder.path_from_webkit_base("LayoutTests", options.destination)
    170170        self.tests_w3c_relative_path = self.filesystem.join('imported', 'w3c')
    171         self.layout_tests_w3c_path = webkit_finder.path_from_webkit_base('LayoutTests', self.tests_w3c_relative_path)
     171        self.layout_tests_path = webkit_finder.path_from_webkit_base('LayoutTests')
     172        self.layout_tests_w3c_path = self.filesystem.join(self.layout_tests_path, self.tests_w3c_relative_path)
    172173        self.tests_download_path = webkit_finder.path_from_webkit_base('WebKitBuild', 'w3c-tests')
    173174
     
    181182        self._test_resource_files_json_path = self.filesystem.join(self.layout_tests_w3c_path, "resources", "resource-files.json")
    182183        self._test_resource_files = json.loads(self.filesystem.read_text_file(self._test_resource_files_json_path)) if self.filesystem.exists(self._test_resource_files_json_path) else None
     184
     185        self._tests_options_json_path = self.filesystem.join(self.layout_tests_path, 'tests-options.json')
     186        self._tests_options = json.loads(self.filesystem.read_text_file(self._tests_options_json_path)) if self.filesystem.exists(self._tests_options_json_path) else None
     187        self._slow_tests = []
     188
    183189        if self.options.clean_destination_directory and self._test_resource_files:
    184190            self._test_resource_files["files"] = []
     191            if self._tests_options:
     192                self.remove_slow_from_w3c_tests_options()
    185193
    186194    def do_import(self):
     
    305313                elif self._is_in_resources_directory(fullpath):
    306314                    _log.warning('%s is a test located in a "resources" folder. This test will be skipped by WebKit test runners.', fullpath)
     315
     316                if 'slow' in test_info:
     317                    self._slow_tests.append(fullpath)
    307318
    308319                if 'manualtest' in test_info.keys():
     
    481492                self.filesystem.write_text_file(self._test_resource_files_json_path, json.dumps(self._test_resource_files, sort_keys=True, indent=4).replace(' \n', '\n'))
    482493
     494        if self._tests_options:
     495            self.update_tests_options()
     496
    483497    def _already_identified_as_resource_file(self, path):
    484498        if path in self._test_resource_files["files"]:
     
    488502    def _is_in_resources_directory(self, path):
    489503        return "resources" in path.split(self.filesystem.sep)
     504
     505    def update_tests_options(self):
     506        should_update = self.options.clean_destination_directory
     507        for full_path in self._slow_tests:
     508            w3c_test_path = self.filesystem.relpath(full_path, self.source_directory)
     509            # No need to mark tests as slow if they are in skipped directories
     510            if self._already_identified_as_resource_file(w3c_test_path):
     511                continue
     512
     513            test_path = self.filesystem.join(self.tests_w3c_relative_path, w3c_test_path)
     514            options = self._tests_options.get(test_path, [])
     515            if not 'slow' in options:
     516                options.append('slow')
     517                self._tests_options[test_path] = options
     518                should_update = True
     519
     520        if should_update:
     521            self.filesystem.write_text_file(self._tests_options_json_path, json.dumps(self._tests_options, sort_keys=True, indent=4).replace(' \n', '\n'))
     522
     523    def remove_slow_from_w3c_tests_options(self):
     524        for test_path in self._tests_options.keys():
     525            if self.tests_w3c_relative_path in test_path:
     526                options = self._tests_options[test_path]
     527                options.remove('slow')
     528                if not options:
     529                    self._tests_options.pop(test_path)
    490530
    491531    def remove_deleted_files(self, import_directory, new_file_list):
  • trunk/Tools/Scripts/webkitpy/w3c/test_parser.py

    r191380 r205476  
    126126            test_info = {'test': self.filename}
    127127
     128        if test_info and self.is_slow_test():
     129            test_info['slow'] = True
     130
    128131        return test_info
    129132
     
    139142        return self.filename.endswith('-manual.htm') or self.filename.endswith('-manual.html')
    140143
     144    def is_slow_test(self):
     145        return any([match.name == 'meta' and match['name'] == 'timeout' for match in self.test_doc.findAll(content='long')])
     146
    141147    def potential_ref_filename(self):
    142148        parts = self.filesystem.splitext(self.filename)
    143         return  parts[0] + '-ref' + parts[1]
     149        return parts[0] + '-ref' + parts[1]
    144150
    145151    def is_wpt_reftest(self):
Note: See TracChangeset for help on using the changeset viewer.