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

Side by Side Diff: Tools/Scripts/webkitpy/w3c/test_parser.py

Issue 15366004: update w3c import script to actually work :). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 3 # Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions 6 # modification, are permitted provided that the following conditions
7 # are met: 7 # are met:
8 # 8 #
9 # 1. Redistributions of source code must retain the above 9 # 1. Redistributions of source code must retain the above
10 # copyright notice, this list of conditions and the following 10 # copyright notice, this list of conditions and the following
(...skipping 29 matching lines...) Expand all
40 self.filename = filename 40 self.filename = filename
41 self.host = Host() 41 self.host = Host()
42 self.filesystem = self.host.filesystem 42 self.filesystem = self.host.filesystem
43 43
44 self.test_doc = None 44 self.test_doc = None
45 self.ref_doc = None 45 self.ref_doc = None
46 self.load_file(filename) 46 self.load_file(filename)
47 47
48 def load_file(self, filename): 48 def load_file(self, filename):
49 if self.filesystem.exists(filename): 49 if self.filesystem.exists(filename):
50 self.test_doc = Parser(self.filesystem.read_text_file(filename)) 50 self.test_doc = Parser(self.filesystem.read_binary_file(filename))
51 else: 51 else:
52 self.test_doc = None 52 self.test_doc = None
53 self.ref_doc = None 53 self.ref_doc = None
54 54
55 def analyze_test(self, test_contents=None, ref_contents=None): 55 def analyze_test(self, test_contents=None, ref_contents=None):
56 """ Analyzes a file to determine if it's a test, what type of test, and what reference or support files it requires. Returns all of the test info """ 56 """ Analyzes a file to determine if it's a test, what type of test, and what reference or support files it requires. Returns all of the test info """
57 57
58 test_info = None 58 test_info = None
59 59
60 if test_contents is None and self.test_doc is None: 60 if test_contents is None and self.test_doc is None:
(...skipping 24 matching lines...) Expand all
85 # 85 #
86 # Note: The test files themselves are not checked for support files 86 # Note: The test files themselves are not checked for support files
87 # outside their directories as the convention in the CSSWG is to 87 # outside their directories as the convention in the CSSWG is to
88 # put all support files in the same dir or subdir as the test. 88 # put all support files in the same dir or subdir as the test.
89 # 89 #
90 # All non-test files in the test's directory tree are normally 90 # All non-test files in the test's directory tree are normally
91 # copied as part of the import as they are assumed to be required 91 # copied as part of the import as they are assumed to be required
92 # support files. 92 # support files.
93 # 93 #
94 # *But*, there is exactly one case in the entire css2.1 suite where 94 # *But*, there is exactly one case in the entire css2.1 suite where
95 # at test depends on a file that lives in a different directory, 95 # a test depends on a file that lives in a different directory,
96 # which depends on another file that lives outside of its 96 # which depends on another file that lives outside of its
97 # directory. This code covers that case :) 97 # directory. This code covers that case :)
98 if matches[0]['href'].startswith('..'): 98 if matches[0]['href'].startswith('..'):
99 support_files = self.support_files(self.ref_doc) 99 support_files = self.support_files(self.ref_doc)
100 test_info['refsupport'] = support_files 100 test_info['refsupport'] = support_files
101 101
102 elif self.is_jstest(): 102 elif self.is_jstest():
103 test_info = {'test': self.filename, 'jstest': True} 103 test_info = {'test': self.filename, 'jstest': True}
104 elif self.options['all'] is True and not('-ref' in self.filename) and no t('reference' in self.filename): 104 elif self.options['all'] is True and not('-ref' in self.filename) and no t('reference' in self.filename):
105 test_info = {'test': self.filename} 105 test_info = {'test': self.filename}
(...skipping 14 matching lines...) Expand all
120 if doc is None: 120 if doc is None:
121 return support_files 121 return support_files
122 122
123 elements_with_src_attributes = doc.findAll(src=re.compile('.*')) 123 elements_with_src_attributes = doc.findAll(src=re.compile('.*'))
124 elements_with_href_attributes = doc.findAll(href=re.compile('.*')) 124 elements_with_href_attributes = doc.findAll(href=re.compile('.*'))
125 125
126 url_pattern = re.compile('url\(.*\)') 126 url_pattern = re.compile('url\(.*\)')
127 urls = [] 127 urls = []
128 for url in doc.findAll(text=url_pattern): 128 for url in doc.findAll(text=url_pattern):
129 url = re.search(url_pattern, url) 129 url = re.search(url_pattern, url)
130 url = re.sub('url\([\'\"]', '', url.group(0)) 130 url = re.sub('url\([\'\"]?', '', url.group(0))
131 url = re.sub('[\'\"]\)', '', url) 131 url = re.sub('[\'\"]?\)', '', url)
132 urls.append(url) 132 urls.append(url)
133 133
134 src_paths = [src_tag['src'] for src_tag in elements_with_src_attributes] 134 src_paths = [src_tag['src'] for src_tag in elements_with_src_attributes]
135 href_paths = [href_tag['href'] for href_tag in elements_with_href_attrib utes] 135 href_paths = [href_tag['href'] for href_tag in elements_with_href_attrib utes]
136 136
137 paths = src_paths + href_paths + urls 137 paths = src_paths + href_paths + urls
138 for path in paths: 138 for path in paths:
139 if not(path.startswith('http:')) and not(path.startswith('mailto:')) : 139 if not(path.startswith('http:')) and not(path.startswith('mailto:')) :
140 support_files.append(path) 140 support_files.append(path)
141 141
142 return support_files 142 return support_files
OLDNEW
« Tools/Scripts/webkitpy/w3c/test_converter.py ('K') | « Tools/Scripts/webkitpy/w3c/test_importer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698