Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/base.py

Issue 2681733005: webkitpy: Consolidate code for MANIFEST.json into wpt_manifest.py (Closed)
Patch Set: Apply review comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 2010 Google Inc. All rights reserved. 1 # Copyright (C) 2010 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 from webkitpy.layout_tests.layout_package.bot_test_expectations import BotTestEx pectationsFactory 50 from webkitpy.layout_tests.layout_package.bot_test_expectations import BotTestEx pectationsFactory
51 from webkitpy.layout_tests.models import test_run_results 51 from webkitpy.layout_tests.models import test_run_results
52 from webkitpy.layout_tests.models.test_configuration import TestConfiguration 52 from webkitpy.layout_tests.models.test_configuration import TestConfiguration
53 from webkitpy.layout_tests.models.test_expectations import SKIP 53 from webkitpy.layout_tests.models.test_expectations import SKIP
54 from webkitpy.layout_tests.port import driver 54 from webkitpy.layout_tests.port import driver
55 from webkitpy.layout_tests.port import server_process 55 from webkitpy.layout_tests.port import server_process
56 from webkitpy.layout_tests.port.factory import PortFactory 56 from webkitpy.layout_tests.port.factory import PortFactory
57 from webkitpy.layout_tests.servers import apache_http 57 from webkitpy.layout_tests.servers import apache_http
58 from webkitpy.layout_tests.servers import pywebsocket 58 from webkitpy.layout_tests.servers import pywebsocket
59 from webkitpy.layout_tests.servers import wptserve 59 from webkitpy.layout_tests.servers import wptserve
60 from webkitpy.w3c.wpt_manifest import WPTManifest
60 61
61 _log = logging.getLogger(__name__) 62 _log = logging.getLogger(__name__)
62 63
63 64
64 # FIXME: This class should merge with WebKitPort now that Chromium behaves mostl y like other webkit ports. 65 # FIXME: This class should merge with WebKitPort now that Chromium behaves mostl y like other webkit ports.
65 class Port(object): 66 class Port(object):
66 """Abstract class for Port-specific hooks for the layout_test package.""" 67 """Abstract class for Port-specific hooks for the layout_test package."""
67 68
68 # Subclasses override this. This should indicate the basic implementation 69 # Subclasses override this. This should indicate the basic implementation
69 # part of the port name, e.g., 'mac', 'win', 'gtk'; there is probably (?) 70 # part of the port name, e.g., 'mac', 'win', 'gtk'; there is probably (?)
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 if self._filesystem.exists(path): 662 if self._filesystem.exists(path):
662 reftest_list.append((expectation, path)) 663 reftest_list.append((expectation, path))
663 if reftest_list: 664 if reftest_list:
664 return reftest_list 665 return reftest_list
665 666
666 # Try to extract information from MANIFEST.json. 667 # Try to extract information from MANIFEST.json.
667 match = re.match(r'external/wpt/(.*)', test_name) 668 match = re.match(r'external/wpt/(.*)', test_name)
668 if not match: 669 if not match:
669 return [] 670 return []
670 path_in_wpt = match.group(1) 671 path_in_wpt = match.group(1)
671 all_items = self._wpt_manifest()['items'] 672 for expectation, ref_path_in_wpt in self._wpt_manifest().extract_referen ce_list(path_in_wpt):
672 if path_in_wpt not in all_items['reftest']: 673 ref_absolute_path = self._filesystem.join(self.layout_tests_dir(), ' external/wpt' + ref_path_in_wpt)
673 return [] 674 reftest_list.append((expectation, ref_absolute_path))
674 for item in all_items['reftest'][path_in_wpt]:
675 for ref_path_in_wpt, expectation in item[1]:
676 ref_absolute_path = self._filesystem.join(self.layout_tests_dir( ), 'external/wpt' + ref_path_in_wpt)
677 reftest_list.append((expectation, ref_absolute_path))
678 return reftest_list 675 return reftest_list
679 676
680 def tests(self, paths): 677 def tests(self, paths):
681 """Return the list of tests found matching paths.""" 678 """Return the list of tests found matching paths."""
682 tests = self.real_tests(paths) 679 tests = self.real_tests(paths)
683 680
684 suites = self.virtual_test_suites() 681 suites = self.virtual_test_suites()
685 if paths: 682 if paths:
686 tests.extend(self._virtual_tests_matching_paths(paths, suites)) 683 tests.extend(self._virtual_tests_matching_paths(paths, suites))
687 else: 684 else:
(...skipping 28 matching lines...) Expand all
716 extension = filesystem.splitext(filename)[1] 713 extension = filesystem.splitext(filename)[1]
717 return extension in Port._supported_file_extensions 714 return extension in Port._supported_file_extensions
718 715
719 def is_test_file(self, filesystem, dirname, filename): 716 def is_test_file(self, filesystem, dirname, filename):
720 match = re.search(r'[/\\]external[/\\]wpt([/\\].*)?$', dirname) 717 match = re.search(r'[/\\]external[/\\]wpt([/\\].*)?$', dirname)
721 if match: 718 if match:
722 if match.group(1): 719 if match.group(1):
723 path_in_wpt = match.group(1)[1:].replace('\\', '/') + '/' + file name 720 path_in_wpt = match.group(1)[1:].replace('\\', '/') + '/' + file name
724 else: 721 else:
725 path_in_wpt = filename 722 path_in_wpt = filename
726 return self._manifest_items_for_path(path_in_wpt) is not None 723 return self._wpt_manifest().is_test_file(path_in_wpt)
727 if 'inspector-unit' in dirname: 724 if 'inspector-unit' in dirname:
728 return filesystem.splitext(filename)[1] == '.js' 725 return filesystem.splitext(filename)[1] == '.js'
729 return Port._has_supported_extension( 726 return Port._has_supported_extension(
730 filesystem, filename) and not Port.is_reference_html_file(filesystem , dirname, filename) 727 filesystem, filename) and not Port.is_reference_html_file(filesystem , dirname, filename)
731 728
732 def _convert_wpt_file_paths_to_url_paths(self, files): 729 def _convert_wpt_file_paths_to_url_paths(self, files):
733 tests = [] 730 tests = []
734 for file_path in files: 731 for file_path in files:
735 # Path separators are normalized by relative_test_filename(). 732 # Path separators are normalized by relative_test_filename().
736 match = re.search(r'external/wpt/(.*)$', file_path) 733 match = re.search(r'external/wpt/(.*)$', file_path)
737 if not match: 734 if not match:
738 tests.append(file_path) 735 tests.append(file_path)
739 continue 736 continue
740 path_in_wpt = match.group(1) 737 urls = self._wpt_manifest().file_path_to_url_paths(match.group(1))
741 manifest_items = self._manifest_items_for_path(path_in_wpt) 738 for url in urls:
742 assert manifest_items is not None 739 tests.append(file_path[0:match.start(1)] + url)
743 if len(manifest_items) != 1:
744 continue
745 url = manifest_items[0][0]
746 if url[1:] != path_in_wpt:
747 # TODO(tkent): foo.any.js and bar.worker.js should be accessed
748 # as foo.any.html, foo.any.worker, and bar.worker with WPTServe.
749 continue
750 tests.append(file_path)
751 return tests 740 return tests
752 741
753 @memoized 742 @memoized
754 def _wpt_manifest(self): 743 def _wpt_manifest(self):
755 path = self._filesystem.join(self.layout_tests_dir(), 'external', 'wpt', 'MANIFEST.json') 744 manifest_path = self._filesystem.join(self.layout_tests_dir(), 'external ', 'wpt', 'MANIFEST.json')
756 return json.loads(self._filesystem.read_text_file(path)) 745 return WPTManifest(self._filesystem.read_text_file(manifest_path))
757
758 def _manifest_items_for_path(self, path_in_wpt):
759 """Returns a manifest item for the given WPT path, or None if not found.
760
761 The format of a manifest item depends on
762 https://github.com/w3c/wpt-tools/blob/master/manifest/item.py
763 and is assumed to be a list of the format [url, extras],
764 or [url, references, extras] for reftests, or None if not found.
765
766 For most testharness tests, the returned manifest_items is expected
767 to look like this:: [["/some/test/path.html", {}]]
768 """
769 items = self._wpt_manifest()['items']
770 if path_in_wpt in items['manual']:
771 return items['manual'][path_in_wpt]
772 elif path_in_wpt in items['reftest']:
773 return items['reftest'][path_in_wpt]
774 elif path_in_wpt in items['testharness']:
775 return items['testharness'][path_in_wpt]
776 return None
777
778 @staticmethod
779 def _get_extras_from_manifest_item(item):
780 return item[-1]
781 746
782 def is_slow_wpt_test(self, test_file): 747 def is_slow_wpt_test(self, test_file):
783 match = re.match(r'external/wpt/(.*)', test_file) 748 match = re.match(r'external/wpt/(.*)', test_file)
784 if not match: 749 if not match:
785 return False 750 return False
786 items = self._manifest_items_for_path(match.group(1)) 751 return self._wpt_manifest().is_slow_test(match.group(1))
787 if not items:
788 return False
789 extras = Port._get_extras_from_manifest_item(items[0])
790 return 'timeout' in extras and extras['timeout'] == 'long'
791 752
792 ALL_TEST_TYPES = ['audio', 'harness', 'pixel', 'ref', 'text', 'unknown'] 753 ALL_TEST_TYPES = ['audio', 'harness', 'pixel', 'ref', 'text', 'unknown']
793 754
794 def test_type(self, test_name): 755 def test_type(self, test_name):
795 fs = self._filesystem 756 fs = self._filesystem
796 if fs.exists(self.expected_filename(test_name, '.png')): 757 if fs.exists(self.expected_filename(test_name, '.png')):
797 return 'pixel' 758 return 'pixel'
798 if fs.exists(self.expected_filename(test_name, '.wav')): 759 if fs.exists(self.expected_filename(test_name, '.wav')):
799 return 'audio' 760 return 'audio'
800 if self.reference_files(test_name): 761 if self.reference_files(test_name):
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 1625
1665 def __init__(self, base, args, reference_args=None): 1626 def __init__(self, base, args, reference_args=None):
1666 self.name = base 1627 self.name = base
1667 self.base = base 1628 self.base = base
1668 self.args = args 1629 self.args = args
1669 self.reference_args = args if reference_args is None else reference_args 1630 self.reference_args = args if reference_args is None else reference_args
1670 self.tests = set() 1631 self.tests = set()
1671 1632
1672 def __repr__(self): 1633 def __repr__(self):
1673 return "PhysicalTestSuite('%s', '%s', %s, %s)" % (self.name, self.base, self.args, self.reference_args) 1634 return "PhysicalTestSuite('%s', '%s', %s, %s)" % (self.name, self.base, self.args, self.reference_args)
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/w3c/test_importer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698